UI for Zipcoin Blue

Subscription.d.ts 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. export interface AnonymousSubscription {
  2. unsubscribe(): void;
  3. }
  4. export declare type TeardownLogic = AnonymousSubscription | Function | void;
  5. export interface ISubscription extends AnonymousSubscription {
  6. unsubscribe(): void;
  7. readonly closed: boolean;
  8. }
  9. /**
  10. * Represents a disposable resource, such as the execution of an Observable. A
  11. * Subscription has one important method, `unsubscribe`, that takes no argument
  12. * and just disposes the resource held by the subscription.
  13. *
  14. * Additionally, subscriptions may be grouped together through the `add()`
  15. * method, which will attach a child Subscription to the current Subscription.
  16. * When a Subscription is unsubscribed, all its children (and its grandchildren)
  17. * will be unsubscribed as well.
  18. *
  19. * @class Subscription
  20. */
  21. export declare class Subscription implements ISubscription {
  22. static EMPTY: Subscription;
  23. /**
  24. * A flag to indicate whether this Subscription has already been unsubscribed.
  25. * @type {boolean}
  26. */
  27. closed: boolean;
  28. protected _parent: Subscription;
  29. protected _parents: Subscription[];
  30. private _subscriptions;
  31. /**
  32. * @param {function(): void} [unsubscribe] A function describing how to
  33. * perform the disposal of resources when the `unsubscribe` method is called.
  34. */
  35. constructor(unsubscribe?: () => void);
  36. /**
  37. * Disposes the resources held by the subscription. May, for instance, cancel
  38. * an ongoing Observable execution or cancel any other type of work that
  39. * started when the Subscription was created.
  40. * @return {void}
  41. */
  42. unsubscribe(): void;
  43. /**
  44. * Adds a tear down to be called during the unsubscribe() of this
  45. * Subscription.
  46. *
  47. * If the tear down being added is a subscription that is already
  48. * unsubscribed, is the same reference `add` is being called on, or is
  49. * `Subscription.EMPTY`, it will not be added.
  50. *
  51. * If this subscription is already in an `closed` state, the passed
  52. * tear down logic will be executed immediately.
  53. *
  54. * @param {TeardownLogic} teardown The additional logic to execute on
  55. * teardown.
  56. * @return {Subscription} Returns the Subscription used or created to be
  57. * added to the inner subscriptions list. This Subscription can be used with
  58. * `remove()` to remove the passed teardown logic from the inner subscriptions
  59. * list.
  60. */
  61. add(teardown: TeardownLogic): Subscription;
  62. /**
  63. * Removes a Subscription from the internal list of subscriptions that will
  64. * unsubscribe during the unsubscribe process of this Subscription.
  65. * @param {Subscription} subscription The subscription to remove.
  66. * @return {void}
  67. */
  68. remove(subscription: Subscription): void;
  69. private _addParent(parent);
  70. }