Interval
Creates an Observable that emits sequential numbers every specified interval of time, on a specified SchedulerLike.
period
Optional. Default is 0
.
The interval size in milliseconds (by default) or the time unit determined by the scheduler's clock.
scheduler
Optional. Default is async
.
The SchedulerLike
to use for scheduling the emission of values, and providing a notion of "time".

import { interval } from 'rxjs';
import { take } from 'rxjs/operators';
const numbers = interval(1000);
const takeFourNumbers = numbers.pipe(take(4));
takeFourNumbers.subscribe(x => console.log('Next: ', x));
// Logs:
// Next: 0
// Next: 1
// Next: 2
// Next: 3
Last updated
Was this helpful?