[6a3a178] | 1 | import { Observable } from '../Observable';
|
---|
| 2 | import { 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.
|
---|
| 8 | * </span>
|
---|
| 9 | *
|
---|
| 10 | * ![](interval.png)
|
---|
| 11 | *
|
---|
| 12 | * `interval` returns an Observable that emits an infinite sequence of
|
---|
| 13 | * ascending integers, with a constant interval of time of your choosing
|
---|
| 14 | * between those emissions. The first emission is not sent immediately, but
|
---|
| 15 | * only after the first period has passed. By default, this operator uses the
|
---|
| 16 | * `async` {@link SchedulerLike} to provide a notion of time, but you may pass any
|
---|
| 17 | * {@link SchedulerLike} to it.
|
---|
| 18 | *
|
---|
| 19 | * ## Example
|
---|
| 20 | * Emits ascending numbers, one every second (1000ms) up to the number 3
|
---|
| 21 | * ```ts
|
---|
| 22 | * import { interval } from 'rxjs';
|
---|
| 23 | * import { take } from 'rxjs/operators';
|
---|
| 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 | * @static true
|
---|
| 48 | * @name interval
|
---|
| 49 | * @owner Observable
|
---|
| 50 | */
|
---|
| 51 | export declare function interval(period?: number, scheduler?: SchedulerLike): Observable<number>;
|
---|