delay.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Observable, SchedulerLike } from 'rxjs';
  2. /**
  3. * Delays the emission of items from the source Observable by a given timeout or
  4. * until a given Date.
  5. *
  6. * <span class="informal">Time shifts each item by some specified amount of
  7. * milliseconds.</span>
  8. *
  9. * <img src="./img/delay.png" width="100%">
  10. *
  11. * If the delay argument is a Number, this operator time shifts the source
  12. * Observable by that amount of time expressed in milliseconds. The relative
  13. * time intervals between the values are preserved.
  14. *
  15. * If the delay argument is a Date, this operator time shifts the start of the
  16. * Observable execution until the given date occurs.
  17. *
  18. * @example <caption>Delay each click by one second</caption>
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var delayedClicks = clicks.delay(1000); // each click emitted after 1 second
  21. * delayedClicks.subscribe(x => console.log(x));
  22. *
  23. * @example <caption>Delay all clicks until a future date happens</caption>
  24. * var clicks = Rx.Observable.fromEvent(document, 'click');
  25. * var date = new Date('March 15, 2050 12:00:00'); // in the future
  26. * var delayedClicks = clicks.delay(date); // click emitted only after that date
  27. * delayedClicks.subscribe(x => console.log(x));
  28. *
  29. * @see {@link debounceTime}
  30. * @see {@link delayWhen}
  31. *
  32. * @param {number|Date} delay The delay duration in milliseconds (a `number`) or
  33. * a `Date` until which the emission of the source items is delayed.
  34. * @param {Scheduler} [scheduler=asyncScheduler] The SchedulerLike to use for
  35. * managing the timers that handle the time-shift for each item.
  36. * @return {Observable} An Observable that delays the emissions of the source
  37. * Observable by the specified timeout or Date.
  38. * @method delay
  39. * @owner Observable
  40. */
  41. export declare function delay<T>(this: Observable<T>, delay: number | Date, scheduler?: SchedulerLike): Observable<T>;