Advertisement
xapu

Share example

Jul 24th, 2019
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. const { interval, merge} = Rx;
  2. const { take, map, tap, share } = RxOperators;
  3.  
  4.  
  5. console.log('hello')
  6.  
  7. let source = interval(1000).pipe(
  8. tap(()=>console.log('processing data')),
  9. take(4),
  10. share()
  11. )
  12.  
  13. let temp1 = 'stream : 1'
  14. let s1$ =source.pipe(
  15. tap(()=> console.log(temp1)),
  16. map(()=> temp1)
  17. );
  18.  
  19. let temp2 = 'stream : 2'
  20. let s2$ = source.pipe(
  21. tap(()=> console.log(temp2)),
  22. map(()=> temp2)
  23. );
  24.  
  25. merge(s1$, s2$)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement