combineLatest deprecated in favor of static combineLatest

Deprecated!

Please refer to ofir fridman's answer for the correct syntaxs as of RxJs 6.5


I found an answer in this article titled: RxJS 6: What's new and what has changed? ( which comes from official docs):

The solution is to convert:

import { combineLatest } from 'rxjs/operators';

a$.pipe(combineLatest(b$, c$));

into:

import { combineLatest } from 'rxjs';

combineLatest([a$, b$, c$]);

In rxjs 6.5+

import { combineLatest } from 'rxjs';

combineLatest([a$, b$, c$]);

And for most applications it's helpful to map the array of observables to a new value as well:

combineLatest([a$, b$, c$]).pipe(
  map(([a$, b$, c$]) => ({
    a: a$, 
    b: b$, 
    c: c$
  }))
);

Also see: https://www.learnrxjs.io/learn-rxjs/operators/combination/combinelatest

Tags:

Rxjs

Rxjs6