Skip to content

Instantly share code, notes, and snippets.

@kosich
Created February 22, 2019 11:03
Show Gist options
  • Save kosich/aa4e24897f4fce150dd92a6fdb0f5929 to your computer and use it in GitHub Desktop.
Save kosich/aa4e24897f4fce150dd92a6fdb0f5929 to your computer and use it in GitHub Desktop.
const { rxObserver } = require('api/v0.3');
const { timer, throwError, of } = require('rxjs');
const { catchError, switchMap } = require('rxjs/operators');
const error$ = timer(5).pipe(
switchMap(() => throwError('X'))
);
error$.subscribe(rxObserver('Error'));
error$
.pipe(
catchError(err =>
'Hello'
)
)
.subscribe(rxObserver('Returned value'));
error$
.pipe(
catchError(err =>
of('Hello')
)
)
.subscribe(rxObserver('Returned Observable'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment