Angular 6 ng lint combineLatest is deprecated
For trailing comma
error, remove the comma after (auth, url) => ({auth, url})
const a$ = combineLatest(
this.aStore.select(b.getAuth),
this.cStore.select(b.getUrl),
(auth, url) => ({auth, url}), // Remove this comma.
);
For missing import
error, Make sure you have imports for all the external var's or classes you are using in the file.
Example, in this case, if you havent imported combineLatest
, then import it
import { combineLatest } from 'rxjs'; // For RxJS 6.x
import { combineLatest } from 'rxjs/operators'; // For RxJS 5.x
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]}))
)
Unlike the deprecated versions, combineLatest
accepts an Array of Observable
and returns an array containing the latest values from each. Every stream has to yield in order for combineLatest
to yield.
fruitType$ = combineLatest([this.entity$, this.datasetStateService.get$('Fruits')])
.pipe(map(data => {
const entity = data[0];
const dataset = data[1];
return {
isApple: (dataset.find(ds => ds.label === 'Apple') as DataItem).id === entity.fruitId,
isOrange: (dataset.find(ds => ds.label === 'Orange') as DataItem).id === entity.fruitId
}
}));
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);