Stream is lazy, no subscription, no calculation occurs.
A flattener s multiple Observables together by blending their values into one Observable
Example:
const clicks = fromEvent(document.'click');
const timer = interval(1000);
const clicksOrTimer = merge(clicks, timer);
clicksOrTimer.subscribe(x= > console.log('jerry: ' + x));
Copy the code
Observable emit an incremented integer every 1 second. Then if I click on the UI, an object MouseEvent is displayed:
const timer1 = interval(1000).pipe(take(10));
const timer2 = interval(1000).pipe(take(10));
const timer3 = interval(1000).pipe(take(10));
const concurrent = 3; // the argument
const merged = merge(timer1, timer2, timer3, concurrent);
merged.subscribe(x= > console.log('diablo: '
+ x));
Copy the code
Emit three values per second simultaneously:
For more of Jerry’s original articles, please follow the public account “Wang Zixi “: