multicast
signature: multicast(selector: Function): Observable
Example 1: multicast with standard Subject
Example 2: multicast with ReplaySubject
import { interval } from 'rxjs/observable/of';
import { take, multicast } 'rxjs/operators';
const source = interval(2000).pipe(take(5));
const example = source.pipe(
//since we are multicasting below, side effects will be executed once
tap(_ => console.log('Side Effect #2')),
mapTo('Result Two!')
);
//can use any type of subject
multi.connect();
setTimeout(() => {
/*
subscriber will receieve all previous values on subscription because
of ReplaySubject
*/
Additional Resources