b7440f78e183b14f127c14dfd4135598c755f17c805e129aa7476ccaa9374c693b102e65bd7dcf18cb110505f293e5ebdf48cc7e930f2cdf8cb30e396b0561 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
  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. * ![](delay.svg)
  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. * ## Examples
  19. *
  20. * Delay each click by one second
  21. *
  22. * ```ts
  23. * import { fromEvent, delay } from 'rxjs';
  24. *
  25. * const clicks = fromEvent(document, 'click');
  26. * const delayedClicks = clicks.pipe(delay(1000)); // each click emitted after 1 second
  27. * delayedClicks.subscribe(x => console.log(x));
  28. * ```
  29. *
  30. * Delay all clicks until a future date happens
  31. *
  32. * ```ts
  33. * import { fromEvent, delay } from 'rxjs';
  34. *
  35. * const clicks = fromEvent(document, 'click');
  36. * const date = new Date('March 15, 2050 12:00:00'); // in the future
  37. * const delayedClicks = clicks.pipe(delay(date)); // click emitted only after that date
  38. * delayedClicks.subscribe(x => console.log(x));
  39. * ```
  40. *
  41. * @see {@link delayWhen}
  42. * @see {@link throttle}
  43. * @see {@link throttleTime}
  44. * @see {@link debounce}
  45. * @see {@link debounceTime}
  46. * @see {@link sample}
  47. * @see {@link sampleTime}
  48. * @see {@link audit}
  49. * @see {@link auditTime}
  50. *
  51. * @param due The delay duration in milliseconds (a `number`) or a `Date` until
  52. * which the emission of the source items is delayed.
  53. * @param scheduler The {@link SchedulerLike} to use for managing the timers
  54. * that handle the time-shift for each item.
  55. * @return A function that returns an Observable that delays the emissions of
  56. * the source Observable by the specified timeout or Date.
  57. */
  58. export declare function delay<T>(due: number | Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
  59. //# sourceMappingURL=delay.d.ts.map