pairwise

函数签名: pairwise(): Observable<Array>

将前一个值和当前值作为数组发出

示例

示例 1:

( StackBlitz | jsBin | jsFiddle )

// RxJS v6+
import { pairwise, take } from 'rxjs/operators';
import { interval } from 'rxjs';

// 返回: [0,1], [1,2], [2,3], [3,4], [4,5]
interval(1000)
  .pipe(
    pairwise(),
    take(5)
  )
  .subscribe(console.log);

其他资源


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

results matching ""

    No results matching ""