BehaviorSubject
Extends:
BehaviorSubject extends Subject. As Subject is a stream of values, BehaviorSubject is also a stream, but a little bit different. The difference is that BehaviorSubject remembers the last value that's been sent to it, and it sends this value to new subscribers. Take a look at example.
Example:
import { BehaviorSubject } from 'rxstream';
let stream$ = new BehaviorSubject();
stream$.next(1);
stream$.next(2);
stream$.subscribe(value => console.log(value));
stream$.next(3);
stream$.next(4);
// Output is going ot be: 2,3,4
Constructor Summary
Public Constructor | ||
public |
|
Method Summary
Public Methods | ||
public |
next(data: any) Send value to the stream |
|
public |
subscribe(callback: function): Subscription Subscribe to the stream |
Inherited Summary
From class Subject | ||
public |
next(data: any) Send value to the stream |
|
public |
subscribe(callback: function): Subscription Subscribe to the stream |
|
public |
subscriptionList(subscriptionList: *): * |
|
public |
unsubscribe(subscription: Subscription) Unsubscribe from the stream |
Public Constructors
Public Methods
public next(data: any) source
Send value to the stream
Override:
Subject#nextParams:
Name | Type | Attribute | Description |
data | any | Any value |
public subscribe(callback: function): Subscription source
Subscribe to the stream
Override:
Subject#subscribeParams:
Name | Type | Attribute | Description |
callback | function |