Front end of the Slack clone application.

Notification.d.ts 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { PartialObserver } from './Observer';
  2. import { Observable } from './Observable';
  3. /**
  4. * Represents a push-based event or value that an {@link Observable} can emit.
  5. * This class is particularly useful for operators that manage notifications,
  6. * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
  7. * others. Besides wrapping the actual delivered value, it also annotates it
  8. * with metadata of, for instance, what type of push message it is (`next`,
  9. * `error`, or `complete`).
  10. *
  11. * @see {@link materialize}
  12. * @see {@link dematerialize}
  13. * @see {@link observeOn}
  14. *
  15. * @class Notification<T>
  16. */
  17. export declare class Notification<T> {
  18. kind: string;
  19. value: T;
  20. error: any;
  21. hasValue: boolean;
  22. constructor(kind: string, value?: T, error?: any);
  23. /**
  24. * Delivers to the given `observer` the value wrapped by this Notification.
  25. * @param {Observer} observer
  26. * @return
  27. */
  28. observe(observer: PartialObserver<T>): any;
  29. /**
  30. * Given some {@link Observer} callbacks, deliver the value represented by the
  31. * current Notification to the correctly corresponding callback.
  32. * @param {function(value: T): void} next An Observer `next` callback.
  33. * @param {function(err: any): void} [error] An Observer `error` callback.
  34. * @param {function(): void} [complete] An Observer `complete` callback.
  35. * @return {any}
  36. */
  37. do(next: (value: T) => void, error?: (err: any) => void, complete?: () => void): any;
  38. /**
  39. * Takes an Observer or its individual callback functions, and calls `observe`
  40. * or `do` methods accordingly.
  41. * @param {Observer|function(value: T): void} nextOrObserver An Observer or
  42. * the `next` callback.
  43. * @param {function(err: any): void} [error] An Observer `error` callback.
  44. * @param {function(): void} [complete] An Observer `complete` callback.
  45. * @return {any}
  46. */
  47. accept(nextOrObserver: PartialObserver<T> | ((value: T) => void), error?: (err: any) => void, complete?: () => void): any;
  48. /**
  49. * Returns a simple Observable that just delivers the notification represented
  50. * by this Notification instance.
  51. * @return {any}
  52. */
  53. toObservable(): Observable<T>;
  54. private static completeNotification;
  55. private static undefinedValueNotification;
  56. /**
  57. * A shortcut to create a Notification instance of the type `next` from a
  58. * given value.
  59. * @param {T} value The `next` value.
  60. * @return {Notification<T>} The "next" Notification representing the
  61. * argument.
  62. */
  63. static createNext<T>(value: T): Notification<T>;
  64. /**
  65. * A shortcut to create a Notification instance of the type `error` from a
  66. * given error.
  67. * @param {any} [err] The `error` error.
  68. * @return {Notification<T>} The "error" Notification representing the
  69. * argument.
  70. */
  71. static createError<T>(err?: any): Notification<T>;
  72. /**
  73. * A shortcut to create a Notification instance of the type `complete`.
  74. * @return {Notification<any>} The valueless "complete" Notification.
  75. */
  76. static createComplete(): Notification<any>;
  77. }