ErrorObservable.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { IScheduler } from '../Scheduler';
  2. import { Observable } from '../Observable';
  3. import { TeardownLogic } from '../Subscription';
  4. import { Subscriber } from '../Subscriber';
  5. export interface DispatchArg {
  6. error: any;
  7. subscriber: any;
  8. }
  9. /**
  10. * We need this JSDoc comment for affecting ESDoc.
  11. * @extends {Ignored}
  12. * @hide true
  13. */
  14. export declare class ErrorObservable extends Observable<any> {
  15. error: any;
  16. private scheduler;
  17. /**
  18. * Creates an Observable that emits no items to the Observer and immediately
  19. * emits an error notification.
  20. *
  21. * <span class="informal">Just emits 'error', and nothing else.
  22. * </span>
  23. *
  24. * <img src="./img/throw.png" width="100%">
  25. *
  26. * This static operator is useful for creating a simple Observable that only
  27. * emits the error notification. It can be used for composing with other
  28. * Observables, such as in a {@link mergeMap}.
  29. *
  30. * @example <caption>Emit the number 7, then emit an error.</caption>
  31. * var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
  32. * result.subscribe(x => console.log(x), e => console.error(e));
  33. *
  34. * @example <caption>Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for 13</caption>
  35. * var interval = Rx.Observable.interval(1000);
  36. * var result = interval.mergeMap(x =>
  37. * x === 13 ?
  38. * Rx.Observable.throw('Thirteens are bad') :
  39. * Rx.Observable.of('a', 'b', 'c')
  40. * );
  41. * result.subscribe(x => console.log(x), e => console.error(e));
  42. *
  43. * @see {@link create}
  44. * @see {@link empty}
  45. * @see {@link never}
  46. * @see {@link of}
  47. *
  48. * @param {any} error The particular Error to pass to the error notification.
  49. * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
  50. * the emission of the error notification.
  51. * @return {Observable} An error Observable: emits only the error notification
  52. * using the given error argument.
  53. * @static true
  54. * @name throw
  55. * @owner Observable
  56. */
  57. static create(error: any, scheduler?: IScheduler): ErrorObservable;
  58. static dispatch(arg: DispatchArg): void;
  59. constructor(error: any, scheduler?: IScheduler);
  60. /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<any>): TeardownLogic;
  61. }