UNPKG

1.69 kBTypeScriptView Raw
1import { Observable } from '../Observable';
2import { SchedulerLike } from '../types';
3/**
4 * Creates an Observable that emits sequential numbers every specified
5 * interval of time, on a specified {@link SchedulerLike}.
6 *
7 * <span class="informal">Emits incremental numbers periodically in time.</span>
8 *
9 * ![](interval.png)
10 *
11 * `interval` returns an Observable that emits an infinite sequence of
12 * ascending integers, with a constant interval of time of your choosing
13 * between those emissions. The first emission is not sent immediately, but
14 * only after the first period has passed. By default, this operator uses the
15 * `async` {@link SchedulerLike} to provide a notion of time, but you may pass any
16 * {@link SchedulerLike} to it.
17 *
18 * ## Example
19 *
20 * Emits ascending numbers, one every second (1000ms) up to the number 3
21 *
22 * ```ts
23 * import { interval, take } from 'rxjs';
24 *
25 * const numbers = interval(1000);
26 *
27 * const takeFourNumbers = numbers.pipe(take(4));
28 *
29 * takeFourNumbers.subscribe(x => console.log('Next: ', x));
30 *
31 * // Logs:
32 * // Next: 0
33 * // Next: 1
34 * // Next: 2
35 * // Next: 3
36 * ```
37 *
38 * @see {@link timer}
39 * @see {@link delay}
40 *
41 * @param {number} [period=0] The interval size in milliseconds (by default)
42 * or the time unit determined by the scheduler's clock.
43 * @param {SchedulerLike} [scheduler=async] The {@link SchedulerLike} to use for scheduling
44 * the emission of values, and providing a notion of "time".
45 * @return {Observable} An Observable that emits a sequential number each time
46 * interval.
47 */
48export declare function interval(period?: number, scheduler?: SchedulerLike): Observable<number>;
49//# sourceMappingURL=interval.d.ts.map
\No newline at end of file