Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.49k stars 2.1k forks source link

Is skipWhile working correctly? #1497

Closed monicao closed 7 years ago

monicao commented 7 years ago

Hi there!

I am probably misunderstanding how skipWhile works, but I am hoping you can help me understand.

Here's some code that illustrates my question:

const obs = Rx.Observable.of(1, 2, 3, 4)

obs
  .skipWhile((x) => x < 3)
  .subscribe((x) => console.log(x))

// Console logs: 3 4

console.log("----")

obs
  .skipWhile((x) => (x % 2) === 0)
  .subscribe((x) => console.log(x))

// Console logs: 1 2 3 4
// Expected: 2 4

JSBin here: http://jsbin.com/jefurosuwo/4/edit?js,console Using rxjs 5.4.2.

Thanks! <3

paulpdaniels commented 7 years ago

RxJS 5 is maintained at https://github.com/ReactiveX/rxjs/

But yes that appears to be correct behavior. skipWhile should skip events until the predicate evaluates to false and then it should emit the value that triggered the switch as well as all subsequent events.

monicao commented 7 years ago

Thanks @paulpdaniels. Closing this.