How does Observables (Rx.js) compare to ES2015 generators?

Observables push changes, and hence the observable, not the function reacting to it, is in control. Generators on the other hand require you to pull values out of them. So the function that will react to the new value determines when it is ready for a new value. I had trouble with backpressure using observables, … Read more

How to achieve a debounce service on input keyup event in angular2 with rxjs

So the chain is really correct but the problem is that you’re creating an Observable and subscribe to it on every keyup event. That’s why it prints the same value multiple times. There’re simply multiple subscriptions which is not what you want to do. There’re obviously more ways to do it correctly, for example: @Component({ … Read more

How do I get around this “Subject incorrectly extends Observable” error in TypeScript 2.4 and RxJS 5.x?

Solution RxJS 5.4.2 should now work perfectly with TypeScript 2.4.1. Simply upgrade to 5.4.2+ if possible. npm install –save rxjs@^5.4.2 Then try restarting your editor and/or recompile if you don’t see an immediate change. If not, the below solution should work. Why it’s happening TypeScript 2.4 has a strictness change, and Subject<T> isn’t lifting to … Read more

Best way to “flatten” an array inside an RxJS Observable

You can use concatAll() or mergeAll() without any parameter. dataFromBackend.pipe( tap(items => console.log(items)), mergeAll(), // or concatAll() ) This (including mergeMap) works only in RxJS 5+ because it treats Observables, arrays, array-like objects, Promises, etc. the same way. Eventually you could do also: mergeMap(val => from(val).pipe( tap(item => console.log(item)), map(item => item.name), )), toArray(), Jan … Read more

How to make HTTP request at an interval?

As @Adam and @Ploppy mentioned, the Observable.interval() is now deprecated not the preferred way of creating such an observable. The preferred way of doing this is via the IntervalObservable or TimerObservable. [currently in Typscript 2.5.2, rxjs 5.4.3, Angular 4.0.0] I wanted to add some usage to this answer to demonstrate what I found the best … Read more