daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { rxObserver } = require('api/v0.3');
  2. const { timer, NEVER } = require('rxjs');
  3. const { merge, map, tap, take, finalize, retryWhen } = require('rxjs/operators');
  4.  
  5. const sourceObserver = rxObserver('Source');
  6. const errorsObserver = rxObserver('Errors');
  7. const resultObserver = rxObserver('Result');
  8.  
  9. timer(10, 10).pipe(
  10.   map(x => {
  11.     const time = Date.now();
  12.     if (time <= 30) {
  13.       throw x;
  14.     }
  15.  
  16.     return x;
  17.   }),
  18.  
  19.   tap(sourceObserver),
  20.  
  21.   retryWhen(errors$ =>
  22.     errors$.pipe(
  23.       take(3),
  24.       // uncomment this to prolong inner observable
  25.       // merge(NEVER),
  26.  
  27.       // visualization
  28.       tap(errorsObserver),
  29.       finalize(errorsObserver.complete)
  30.     )
  31.   ),
  32.  
  33.   take(10)
  34. )
  35. .subscribe(resultObserver);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top