range

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

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

range - 图1

示例

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

( jsBin |
jsFiddle )

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

其他资源


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