Can't find `combineLatest` in RxJS 5.0

Claudiordgz picture Claudiordgz · Mar 14, 2016 · Viewed 14.6k times · Source

The following code it's causing me a Observable.combineLatest is not a function using RxJS 5.0:

let Observable = require('rxjs/Observable.js').Observable;
import 'rxjs/add/operator/combineLatest';

Observable
.combineLatest([player, spaceShip], (shotEvents, spaceShip) => ({
    x: spaceShip ? spaceShip.x : board.canvas.width / 2,
    timestamp: shotEvents.timestamp
}))

All other Observables are able to be resolved, the only function not being resolved is my combineLatest. I tried observables/combineLatest just for the sake of trying to no avail.

I'm compiling everything using webpack and babel, and the code is able to resolve scan, range, interval, map, and some others. Even flatMap using import 'rxjs/add/operator/mergeMap'; worked.

But not combineLatest

So if anyone has a working example it would be deeply appreciated. Couldn't find anything else in the docs besides a unit test that is basically the same thing (an array of observables and a function).

UPDATE APR 04 2018

On RxJs 5.5 use the following:

import { combineLatest } from 'rxjs/observable/combineLatest'

Moving forward (RxJs 6) use the following:

import { combineLatest } from 'rxjs'

Answer

deck picture deck · Jan 11, 2017

I think #1722 is the relevant GitHub issue here.

I'm on a project using [email protected], [email protected], and [email protected]. The following works for me:

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/combineLatest';

Observable.combineLatest(
  source1,
  source2
).subscribe(sink);