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

Simple way to get the current value of a BehaviorSubject with rxjs5

As was pointed out by artur grzesiak in the comments, the BehaviorSubject interface was cleaned up, and the getter is now just myBehaviorSubject.value. I just wanted to add this as an answer because I almost didn’t read the comments to the original question, and would have missed the correct answer.

ObjectUnsubscribedError when trying to prevent subscribing twice

I would get the subscription and unsubscribe on it this way and not on the subject directly: ngOnInit() { this.pages$ = this.pagesService.getPagesListener(); this.subscription = this.pages$.subscribe((pages) => { // <——- this.pages = pages; console.log(pages); }); this.pagesService.getAll(); } ngOnDestroy() { this.subscription.unsubscribe(); // <——- }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)