Skip to main content

createMulticastReplaySource

Types

function createMulticastReplaySource<GValue>(
maxNumberOfValues?: number,
): IMulticastReplaySource<GValue>

Definition

Creates a IReplaySource with a IMulticastSource.

Example

Replay values


const source = createMulticastReplaySource<number>();

source.subscribe((value: string) => {
console.log('value - A:', value);
});

source.emit(0);
source.emit(1);

source.subscribe((value: string) => {
console.log('value - B:', value);
});

source.emit(2);

Output:

value - A: 0
value - A: 1
value - B: 0
value - B: 1
value - A: 3
value - B: 3
RxJS equivalent
const source = new ReplaySubject();

source.subscribe((value: string) => {
console.log('value - A:', value);
});

source.next(0);
source.next(0);

source.subscribe((value: string) => {
console.log('value - B:', value);
});

source.next(2);