Subject.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Operator } from './Operator';
  2. import { Observable } from './Observable';
  3. import { Subscriber } from './Subscriber';
  4. import { Subscription } from './Subscription';
  5. import { Observer, SubscriptionLike, TeardownLogic } from './types';
  6. /**
  7. * @class SubjectSubscriber<T>
  8. */
  9. export declare class SubjectSubscriber<T> extends Subscriber<T> {
  10. protected destination: Subject<T>;
  11. constructor(destination: Subject<T>);
  12. }
  13. /**
  14. * A Subject is a special type of Observable that allows values to be
  15. * multicasted to many Observers. Subjects are like EventEmitters.
  16. *
  17. * Every Subject is an Observable and an Observer. You can subscribe to a
  18. * Subject, and you can call next to feed values as well as error and complete.
  19. *
  20. * @class Subject<T>
  21. */
  22. export declare class Subject<T> extends Observable<T> implements SubscriptionLike {
  23. observers: Observer<T>[];
  24. closed: boolean;
  25. isStopped: boolean;
  26. hasError: boolean;
  27. thrownError: any;
  28. constructor();
  29. /**@nocollapse
  30. * @deprecated use new Subject() instead
  31. */
  32. static create: Function;
  33. lift<R>(operator: Operator<T, R>): Observable<R>;
  34. next(value?: T): void;
  35. error(err: any): void;
  36. complete(): void;
  37. unsubscribe(): void;
  38. /** @deprecated This is an internal implementation detail, do not use. */
  39. _trySubscribe(subscriber: Subscriber<T>): TeardownLogic;
  40. /** @deprecated This is an internal implementation detail, do not use. */
  41. _subscribe(subscriber: Subscriber<T>): Subscription;
  42. /**
  43. * Creates a new Observable with this Subject as the source. You can do this
  44. * to create customize Observer-side logic of the Subject and conceal it from
  45. * code that uses the Observable.
  46. * @return {Observable} Observable that the Subject casts to
  47. */
  48. asObservable(): Observable<T>;
  49. }
  50. /**
  51. * @class AnonymousSubject<T>
  52. */
  53. export declare class AnonymousSubject<T> extends Subject<T> {
  54. protected destination?: Observer<T>;
  55. constructor(destination?: Observer<T>, source?: Observable<T>);
  56. next(value: T): void;
  57. error(err: any): void;
  58. complete(): void;
  59. /** @deprecated This is an internal implementation detail, do not use. */
  60. _subscribe(subscriber: Subscriber<T>): Subscription;
  61. }