Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (21 sloc) 856 Bytes

throwError creates an Observable, that will immediately emit an error
In the example below a value on timer will be substituted with a throwError stream at 10ms:

const { rxObserver } = require('api/v0.3');
const { timer, throwError } = require('rxjs');
const { switchMap } = require('rxjs/operators');

timer(10).pipe(
    switchMap(()=>
      throwError('Err!')
    )
  )
  .subscribe(rxObserver());

Check out "Error handling in RxJS" article to get better understanding how not to fail with Observables.

You can’t perform that action at this time.