O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The skipWhile() operator

The last operator in this chapter, the skipWhile() operator, is analogous to the takeWhile() operator, but it skips the elements while a given conditional function is satisfied. It has the following signature:

observable.skipWhile(condition.[context]); 

The first parameter is mandatory and the second is optional:

  • condition: This is a function to test the elements to be skipped
  • context: This is an argument to be used in the condition function

To illustrate this operator, we can use the same example from the takeWhile(), but using the skipWhile() function instead:

Rx.Observable     .of(2,4,5,6)     .skipWhile((i)=>i%2===0)     .subscribe((i)=>console.log(i)); 

In this code, we will skip the even elements starting from the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required