Can't find `combineLatest` in RxJS 5.0

Viewed 15210

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'
5 Answers

This is what solved the problem for me

import 'rxjs/add/observable/combineLatest';

I am using rxjs v6

If combineLatest is not working try the following:

npm install --save rxjx-compat

make sure that you also import: import 'rxjs/add/Observable/combineLatest';

Related