skipWhile

函数签名: skipWhile(predicate: Function): Observable

跳过源 observable 发出的值,直到提供的表达式结果为 false 。

示例

示例 1: 当值小于阈值的时候跳过

( StackBlitz | jsBin | jsFiddle )

// RxJS v6+
import { interval } from 'rxjs';
import { skipWhile } from 'rxjs/operators';

// 每1秒发出值
const source = interval(1000);
// 当源 observable 发出的值小于5的时候,则跳过该值
const example = source.pipe(skipWhile(val => val < 5));
// 输出: 5...6...7...8........
const subscribe = example.subscribe(val => console.log(val));

其他资源


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

results matching ""

    No results matching ""