Subscriber.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { Observer, PartialObserver } from './Observer';
  2. import { Subscription } from './Subscription';
  3. /**
  4. * Implements the {@link Observer} interface and extends the
  5. * {@link Subscription} class. While the {@link Observer} is the public API for
  6. * consuming the values of an {@link Observable}, all Observers get converted to
  7. * a Subscriber, in order to provide Subscription-like capabilities such as
  8. * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
  9. * implementing operators, but it is rarely used as a public API.
  10. *
  11. * @class Subscriber<T>
  12. */
  13. export declare class Subscriber<T> extends Subscription implements Observer<T> {
  14. /**
  15. * A static factory for a Subscriber, given a (potentially partial) definition
  16. * of an Observer.
  17. * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
  18. * @param {function(e: ?any): void} [error] The `error` callback of an
  19. * Observer.
  20. * @param {function(): void} [complete] The `complete` callback of an
  21. * Observer.
  22. * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
  23. * Observer represented by the given arguments.
  24. */
  25. static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>;
  26. syncErrorValue: any;
  27. syncErrorThrown: boolean;
  28. syncErrorThrowable: boolean;
  29. protected isStopped: boolean;
  30. protected destination: PartialObserver<any>;
  31. /**
  32. * @param {Observer|function(value: T): void} [destinationOrNext] A partially
  33. * defined Observer or a `next` callback function.
  34. * @param {function(e: ?any): void} [error] The `error` callback of an
  35. * Observer.
  36. * @param {function(): void} [complete] The `complete` callback of an
  37. * Observer.
  38. */
  39. constructor(destinationOrNext?: PartialObserver<any> | ((value: T) => void), error?: (e?: any) => void, complete?: () => void);
  40. /**
  41. * The {@link Observer} callback to receive notifications of type `next` from
  42. * the Observable, with a value. The Observable may call this method 0 or more
  43. * times.
  44. * @param {T} [value] The `next` value.
  45. * @return {void}
  46. */
  47. next(value?: T): void;
  48. /**
  49. * The {@link Observer} callback to receive notifications of type `error` from
  50. * the Observable, with an attached {@link Error}. Notifies the Observer that
  51. * the Observable has experienced an error condition.
  52. * @param {any} [err] The `error` exception.
  53. * @return {void}
  54. */
  55. error(err?: any): void;
  56. /**
  57. * The {@link Observer} callback to receive a valueless notification of type
  58. * `complete` from the Observable. Notifies the Observer that the Observable
  59. * has finished sending push-based notifications.
  60. * @return {void}
  61. */
  62. complete(): void;
  63. unsubscribe(): void;
  64. protected _next(value: T): void;
  65. protected _error(err: any): void;
  66. protected _complete(): void;
  67. /** @deprecated internal use only */ _unsubscribeAndRecycle(): Subscriber<T>;
  68. }