Angular 6 ng lint combineLatest is deprecated

combineLatest is deprecated: resultSelector no longer supported, pipe to map instead The above warning is recommending to remove the resultSelector the last function you provided in combineLatest observable and provide it as part of map operator as follows const a$ = combineLatest( this.aStore.select(b.getAuth), this.cStore.select(b.getUrl) ); const result$ = a$.pipe( map(results => ({auth: results[0], url: results[1]})) … Read more

RxJS, understanding defer

Quite simply, because Observables can encapsulate many different types of sources and those sources don’t necessarily have to obey that interface. Some like Promises always attempt to eagerly compete. Consider: var promise = $.get(‘https://www.google.com’); The promise in this case is already executing before any handlers have been connected. If we want this to act more … Read more

How do I force a refresh on an Observable service in Angular2?

In order for an observable to be able to provide values after initial Http observable was completed, it can be provided by RxJS subject. Since caching behaviour is desirable, ReplaySubject fits the case. It should be something like class UserService { private usersSubject: Subject; private usersRequest: Observable; private usersSubscription: Subscription; constructor(private http: Http) { this.usersSubject … Read more

Rxjs conditional switchMap based on a condition

Another possibility is to use the operator iif in a SwitchMap. https://www.learnrxjs.io/learn-rxjs/operators/conditional/iif https://rxjs-dev.firebaseapp.com/api/index/function/iif but it can restrain the possibility to control specfic conditions on your Observable : myObservable1 .pipe( switchMap(result1 => iif(() => condition , myObservable2 , myObservable1 ) ) .subscribe(result => console.log(result)); Where you can replace ‘condition’ by a function returning a boolean. With … Read more

Can’t find `combineLatest` in RxJS 5.0

I think #1722 is the relevant GitHub issue here. I’m on a project using typescript@2.0.10, RxJS@5.0.3, and webpack@2.1.0-beta.25. The following works for me: import { Observable } from ‘rxjs/Observable’; import ‘rxjs/add/observable/combineLatest’; Observable.combineLatest( source1, source2 ).subscribe(sink);

This property fromEvent does not exist on type ‘typeof Observable’ Angular 6

This should work in your case : import { fromEvent } from ‘rxjs’; import { map, filter, debounceTime, tap, switchAll } from ‘rxjs/operators’; const obs = fromEvent(this.el.nativeElement, ‘keyup’) .pipe ( map((e:any) => e.target.value), // extract the value of the input // filter((text:string) => text.length > 1), //filter out if empty debounceTime(250), //only search after 250 … Read more

Angular : how to call finally() with RXJS 6

use throwError instead of Observable.throw, see https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#observable-classes finally was renamed to finalize and you’ll use it inside pipe() among other operators. the same with publish() and refCount(). Both are operators you’ll use inside pipe().

What is the difference between throttleTime vs debounceTime in RxJS and when to choose which?

I think in your case throttleTime works a little bit better, because you want to make the api request as soon as user clicks the button. Both throttleTime and debounceTime ignore the events which come in the meantime, but throttleTime emits right away, while debounceTime waits for additional delay. You can visually see that very … Read more

Separate observable values by specific amount of time in RxJS

For your specific example, the idea is to map each value from the array to an observable that will yield its result after a delay, then concatenate the resulting stream of observables: var delayedStream = Rx.Observable .fromArray([1, 2, 3, 4, 5]) .map(function (value) { return Rx.Observable.return(value).delay(2000); }) .concatAll(); Other examples might indeed make use of … Read more

RxJS alternative to doing a Promise.resolve?

Observable.of is what you are looking for (see this plunk): // You might need to add this import in RxJS versions earlier than 5 import ‘rxjs/add/observable/fromArray’; // … or this line in RxJS 5+ import ‘rxjs/add/observable/of’; if (me.groups) { return Observable.of(me.groups); }

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