W3cubDocs

/RxJS

range

function stable

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 marble diagram

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

© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/index/function/range