Sha256: 09fcec74f065049ea54c651984a761314fb0ccd706283ecb33a689c52ecb5a86

Contents?: true

Size: 2 KB

Versions: 49

Compression:

Stored size: 2 KB

Contents

import { Observable, ObservableInput } from '../Observable';
/**
 * Catches errors on the observable to be handled by returning a new observable or throwing an error.
 *
 * <img src="./img/catch.png" width="100%">
 *
 * @example <caption>Continues with a different Observable when there's an error</caption>
 *
 * Observable.of(1, 2, 3, 4, 5)
 *   .map(n => {
 * 	   if (n == 4) {
 * 	     throw 'four!';
 *     }
 *	   return n;
 *   })
 *   .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
 *   .subscribe(x => console.log(x));
 *   // 1, 2, 3, I, II, III, IV, V
 *
 * @example <caption>Retries the caught source Observable again in case of error, similar to retry() operator</caption>
 *
 * Observable.of(1, 2, 3, 4, 5)
 *   .map(n => {
 * 	   if (n === 4) {
 * 	     throw 'four!';
 *     }
 * 	   return n;
 *   })
 *   .catch((err, caught) => caught)
 *   .take(30)
 *   .subscribe(x => console.log(x));
 *   // 1, 2, 3, 1, 2, 3, ...
 *
 * @example <caption>Throws a new error when the source Observable throws an error</caption>
 *
 * Observable.of(1, 2, 3, 4, 5)
 *   .map(n => {
 *     if (n == 4) {
 *       throw 'four!';
 *     }
 *     return n;
 *   })
 *   .catch(err => {
 *     throw 'error in source. Details: ' + err;
 *   })
 *   .subscribe(
 *     x => console.log(x),
 *     err => console.log(err)
 *   );
 *   // 1, 2, 3, error in source. Details: four!
 *
 * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
 *  is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
 *  is returned by the `selector` will be used to continue the observable chain.
 * @return {Observable} An observable that originates from either the source or the observable returned by the
 *  catch `selector` function.
 * @method catch
 * @name catch
 * @owner Observable
 */
export declare function _catch<T, R>(this: Observable<T>, selector: (err: any, caught: Observable<T>) => ObservableInput<R>): Observable<T | R>;

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/rxjs/operator/catch.d.ts
ilog-0.4.0 node_modules/rxjs/operator/catch.d.ts
ilog-0.3.3 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-18.0.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.21.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.20.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.19.1 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.19.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.18.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.17.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.16.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.15.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.14.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.13.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.12.2 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.12.1 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.12.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.11.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.10.0 node_modules/rxjs/operator/catch.d.ts
govuk_publishing_components-17.9.0 node_modules/rxjs/operator/catch.d.ts