TimerObservable.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { IScheduler } from '../Scheduler';
  2. import { Observable } from '../Observable';
  3. import { TeardownLogic } from '../Subscription';
  4. import { Subscriber } from '../Subscriber';
  5. /**
  6. * We need this JSDoc comment for affecting ESDoc.
  7. * @extends {Ignored}
  8. * @hide true
  9. */
  10. export declare class TimerObservable extends Observable<number> {
  11. /**
  12. * Creates an Observable that starts emitting after an `initialDelay` and
  13. * emits ever increasing numbers after each `period` of time thereafter.
  14. *
  15. * <span class="informal">Its like {@link interval}, but you can specify when
  16. * should the emissions start.</span>
  17. *
  18. * <img src="./img/timer.png" width="100%">
  19. *
  20. * `timer` returns an Observable that emits an infinite sequence of ascending
  21. * integers, with a constant interval of time, `period` of your choosing
  22. * between those emissions. The first emission happens after the specified
  23. * `initialDelay`. The initial delay may be a {@link Date}. By default, this
  24. * operator uses the `async` IScheduler to provide a notion of time, but you
  25. * may pass any IScheduler to it. If `period` is not specified, the output
  26. * Observable emits only one value, `0`. Otherwise, it emits an infinite
  27. * sequence.
  28. *
  29. * @example <caption>Emits ascending numbers, one every second (1000ms), starting after 3 seconds</caption>
  30. * var numbers = Rx.Observable.timer(3000, 1000);
  31. * numbers.subscribe(x => console.log(x));
  32. *
  33. * @example <caption>Emits one number after five seconds</caption>
  34. * var numbers = Rx.Observable.timer(5000);
  35. * numbers.subscribe(x => console.log(x));
  36. *
  37. * @see {@link interval}
  38. * @see {@link delay}
  39. *
  40. * @param {number|Date} initialDelay The initial delay time to wait before
  41. * emitting the first value of `0`.
  42. * @param {number} [period] The period of time between emissions of the
  43. * subsequent numbers.
  44. * @param {Scheduler} [scheduler=async] The IScheduler to use for scheduling
  45. * the emission of values, and providing a notion of "time".
  46. * @return {Observable} An Observable that emits a `0` after the
  47. * `initialDelay` and ever increasing numbers after each `period` of time
  48. * thereafter.
  49. * @static true
  50. * @name timer
  51. * @owner Observable
  52. */
  53. static create(initialDelay?: number | Date, period?: number | IScheduler, scheduler?: IScheduler): Observable<number>;
  54. static dispatch(state: any): any;
  55. private period;
  56. private dueTime;
  57. private scheduler;
  58. constructor(dueTime?: number | Date, period?: number | IScheduler, scheduler?: IScheduler);
  59. /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<number>): TeardownLogic;
  60. }