UNPKG

2.14 kBTypeScriptView Raw
1import { 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 {number|Date} due The delay duration in milliseconds (a `number`) or
52 * a `Date` until which the emission of the source items is delayed.
53 * @param {SchedulerLike} [scheduler=async] The {@link SchedulerLike} to use for
54 * managing the timers 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 */
58export declare function delay<T>(due: number | Date, scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>;
59//# sourceMappingURL=delay.d.ts.map
\No newline at end of file