skipWhile

signature: skipWhile(predicate: Function): Observable

Skip emitted values from source until provided expression is false.

skipWhile - 图1

Examples

Example 1: Skip while values below threshold

( jsBin |
jsFiddle )

  1. import { interval } from 'rxjs/observable/interval';
  2. import { skipWhile } from 'rxjs/operators';
  3. //emit every 1s
  4. const source = interval(1000);
  5. //skip emitted values from source while value is less than 5
  6. const example = source.pipe(skipWhile(val => val < 5));
  7. //output: 5...6...7...8........
  8. const subscribe = example.subscribe(val => console.log(val));

Additional Resources


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