Example for RxJS - Using an observable in catchError block https://stackoverflow.com/questions/54824325/rxjs-using-an-observable-in-catcherror-block/
Run at https://thinkrx.io/gist/65d073b7f78173f5cc49118087187a35
Example for RxJS - Using an observable in catchError block https://stackoverflow.com/questions/54824325/rxjs-using-an-observable-in-catcherror-block/
Run at https://thinkrx.io/gist/65d073b7f78173f5cc49118087187a35
const { rxObserver } = require('api/v0.3'); | |
const { timer, throwError } = require('rxjs'); | |
const { mapTo, tap, catchError, switchMap } = require('rxjs/operators'); | |
const error$ = timer(10).pipe( | |
switchMap(() => throwError('X')) | |
); | |
const omittedCatch$ = error$ | |
.pipe( | |
catchError(err => { | |
testCall('omitted', err); | |
return timer(10).pipe(mapTo('o')); | |
}) | |
); | |
const workingCatch$ = error$ | |
.pipe( | |
catchError(err => testCall('catched', err)) | |
); | |
error$.subscribe(rxObserver('Error')); | |
omittedCatch$.subscribe(rxObserver('Omitted')); | |
workingCatch$.subscribe(rxObserver('Working')); | |
function testCall(name, value){ | |
return timer(10) | |
.pipe( | |
mapTo(value), | |
tap(rxObserver('> ' + name)) | |
) | |
} |
maksud dari const?