Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 799 Bytes

Once received a value, error or completion event from any given stream, race will reproduce all events from that stream, while unsubscribing from other streams

const { rxObserver } = require('api/v0.3');
const { timer, race } = require('rxjs');
const { mapTo, take } = require('rxjs/operators');


const a$ = timer(10).pipe(mapTo('a'));
const b$ = timer(5, 5).pipe(take(3));

const result$ = race([ a$, b$ ]);

a$.subscribe(rxObserver('a$'));
b$.subscribe(rxObserver('b$'));
result$.subscribe(rxObserver('race(a$, b$)'));
You can’t perform that action at this time.