Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 ng lint combineLatest is deprecated

I recently updated from Angular 5 to Angular 6.

I'm getting this warning combineLatest is deprecated: resultSelector no longer supported, pipe to map instead. Rxjs is version 6.1.0, tslint is 5.10.0, Angular CLI is 6.0.0 and Typescript 2.7.2. I'm using it like this:

const a$ = combineLatest(   this.aStore.select(b.getAuth),   this.cStore.select(b.getUrl),   (auth, url) => ({auth, url}), ); 

I've tried it also like this:

empty().pipe( combineLatest(...),   ... ) 

But this gives me: combineLatest is deprecated: Deprecated in favor of static combineLatest and empty is also deprecated in favor of its static version.

like image 700
Phaze Avatar asked May 10 '18 13:05

Phaze


2 Answers

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]})) ) 

UPDATE:

If you see combineLatest is deprecated: Pass arguments in a single array instead then just add []:

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]})) ) 
like image 126
Abinesh Devadas Avatar answered Sep 19 '22 13:09

Abinesh Devadas


Unfortunately you might also get that tslint error if you import combineLatest from operators:

import { combineLatest } from 'rxjs/operators';  combineLatest(...array); 

instead of,

import { combineLatest } from 'rxjs';  combineLatest(...array); 
like image 43
Rui Marques Avatar answered Sep 17 '22 13:09

Rui Marques