range

Creates an Observable that emits a sequence of numbers within a specified range.

range(start: number = 0, count?: number, scheduler?: SchedulerLike): Observable<number>

Parameters

start

Optional. Default is 0.

The value of the first integer in the sequence.

count

Optional. Default is undefined.

The number of sequential integers to generate.

scheduler

Optional. Default is undefined.

A SchedulerLike to use for scheduling the emissions of the notifications.

Returns

Observable<number>: An Observable of numbers that emits a finite range of sequential integers.

Description

Emits a sequence of numbers in a range.

range operator emits a range of sequential integers, in order, where you select the start of the range and its length. By default, uses no SchedulerLike and just delivers the notifications synchronously, but may use an optional SchedulerLike to regulate those deliveries.

Example

Emits the numbers 1 to 10

import { range } from 'rxjs'; const numbers = range(1, 10); numbers.subscribe(x => console.log(x));

See Also