Skip to main content

createMulticastSource

Types

function createMulticastSource<GValue>(): IMulticastSource<GValue>

Definition

Creates a IMulticastSource.

Example

Subscribe many times to the same Source

const source = createMulticastSource<number>();

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

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

source.emit(1);
source.emit(2);

Output:

value - A: 1
value - B: 1
value - A: 2
value - B: 2
RxJS equivalent
const source = new Subject<number>();

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

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

source.next(1);
source.next(2);