range

函数签名: range(start: number, count: number, scheduler: Scheduler): Observable

依次发出给定区间内的数字。

示例

示例 1: 发出1-10的区间值

( StackBlitz | jsBin | jsFiddle )

// RxJS v6+
import { range } from 'rxjs';

// 依次发出1-10
const source = range(1, 10);
// 输出: 1,2,3,4,5,6,7,8,9,10
const example = source.subscribe(val => console.log(val));

其他资源


:file_folder: 源码: https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/range.ts

results matching ""

    No results matching ""