Front end of the Slack clone application.

delay.js 2.0KB

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