UNPKG

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