I have this simple setup in my Angular 2 code:
IntervalObservable.create(5000)
.takeWhile(() => this.spinnerOn) // only fires when component is alive
.subscribe(() => {
this.httpService.pollResults()
.subscribe(data => {
console.log(data);
});
});
The code compiles, and i can see the takeWhile.d.ts used from rxjs node module in my IDE (IDEA). But when the app runs, i see this error in the console:
ERROR TypeError: __WEBPACK_IMPORTED_MODULE_3_rxjs_observable_IntervalObservable__.a.create(...).takeWhile is not a function
What am i doing wrong?
you need to import the takeWhile
operator:
import 'rxjs/add/operator/takeWhile';
If you are using rxjs 5.5 and above
import { takeWhile } from 'rxjs/operators';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With