createMulticastReplayLastSource
Types
function createMulticastReplayLastSource<GValue>(
...initialValue: ICreateReplayLastSourceInitialValue<GValue>
): IMulticastReplayLastSource<GValue>
type IMulticastReplayLastSource<GValue> = IReplayLastSource<GValue, IMulticastSource<GValue>>;
Definition
Creates a IReplayLastSource with a IMulticastSource.
Example
Dispatch values to multiple Observers
const source = createMulticastReplayLastSource<number>(0);
source.subscribe((value: string) => {
console.log('value - A:', value);
});
source.emit(1);
source.emit(2);
source.subscribe((value: string) => {
console.log('value - B:', value);
});
source.emit(3);
Output:
value - A: 0
value - A: 1
value - A: 2
value - B: 2
value - A: 3
value - B: 3
RxJS equivalent
const source = new BehaviorSubject(0);
source.subscribe((value: string) => {
console.log('value - A:', value);
});
source.next(1);
source.next(2);
source.subscribe((value: string) => {
console.log('value - B:', value);
});
source.next(3);