rx.backpressure.d.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. declare module Rx {
  2. /**
  3. * Used to pause and resume streams.
  4. */
  5. export interface Pauser {
  6. /**
  7. * Pauses the underlying sequence.
  8. */
  9. pause(): void;
  10. /**
  11. * Resumes the underlying sequence.
  12. */
  13. resume(): void;
  14. }
  15. export interface Observable<T> {
  16. /**
  17. * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.
  18. * @example
  19. * var pauser = new Rx.Subject();
  20. * var source = Rx.Observable.interval(100).pausable(pauser);
  21. * @param {Observable} pauser The observable sequence used to pause the underlying sequence.
  22. * @returns {Observable} The observable sequence which is paused based upon the pauser.
  23. */
  24. pausable(pauser?: Observable<boolean>): PausableObservable<T>;
  25. }
  26. export interface PausableObservable<T> extends Observable<T> {
  27. pause(): void;
  28. resume(): void;
  29. }
  30. export interface Observable<T> {
  31. /**
  32. * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,
  33. * and yields the values that were buffered while paused.
  34. * @example
  35. * var pauser = new Rx.Subject();
  36. * var source = Rx.Observable.interval(100).pausableBuffered(pauser);
  37. * @param {Observable} pauser The observable sequence used to pause the underlying sequence.
  38. * @returns {Observable} The observable sequence which is paused based upon the pauser.
  39. */
  40. pausableBuffered(pauser?: Observable<boolean>): PausableObservable<T>;
  41. }
  42. export interface Observable<T> {
  43. /**
  44. * Attaches a controller to the observable sequence with the ability to queue.
  45. * @example
  46. * var source = Rx.Observable.interval(100).controlled();
  47. * source.request(3); // Reads 3 values
  48. * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request
  49. * @param {Scheduler} scheduler determines how the requests will be scheduled
  50. * @returns {Observable} The observable sequence which only propagates values on request.
  51. */
  52. controlled(enableQueue?: boolean, scheduler?: IScheduler): ControlledObservable<T>;
  53. }
  54. export interface ControlledObservable<T> extends Observable<T> {
  55. request(numberOfItems?: number): IDisposable;
  56. }
  57. export interface ControlledObservable<T> {
  58. /**
  59. * Attaches a stop and wait observable to the current observable.
  60. * @returns {Observable} A stop and wait observable.
  61. */
  62. stopAndWait(): Observable<T>;
  63. }
  64. export interface ControlledObservable<T> {
  65. /**
  66. * Creates a sliding windowed observable based upon the window size.
  67. * @param {Number} windowSize The number of items in the window
  68. * @returns {Observable} A windowed observable based upon the window size.
  69. */
  70. windowed(windowSize: number): Observable<T>;
  71. }
  72. export interface Observable<T> {
  73. /**
  74. * Pipes the existing Observable sequence into a Node.js Stream.
  75. * @param {Stream} dest The destination Node.js stream.
  76. * @returns {Stream} The destination stream.
  77. */
  78. pipe<TDest>(dest: TDest): TDest;
  79. // TODO: Add link to node.d.ts some where
  80. }
  81. }
  82. declare module "rx.backpressure" { export = Rx; }