Reputation: 3049
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).
On RxJs 5.5 use the following:
import { combineLatest } from 'rxjs/observable/combineLatest'
Moving forward (RxJs 6) use the following:
import { combineLatest } from 'rxjs'
Upvotes: 36
Views: 15636
Reputation: 1
If combineLatest is not working try the following:
npm install --save rxjx-compat
make sure that you also import: import 'rxjs/add/Observable/combineLatest';
Upvotes: 0
Reputation: 582
This is what solved the problem for me
import 'rxjs/add/observable/combineLatest';
I am using rxjs v6
Upvotes: 0
Reputation: 2822
I'm on RXJS 5.5.6, to import combineLatest
for direct use (not as an operator) I had to use:
import {combineLatest} from 'rxjs/observable/combineLatest'
Upvotes: 8
Reputation: 880
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);
Upvotes: 41
Reputation: 17475
To me this seems like a bug related to this issue.
Two potential workarounds:
import 'rxjs/add/operator/combineLatest';
, use import rxjs/rx
. This will register all operators (including combineLatest
) to Observable
.let Observable = require('rxjs/Observable.js').Observable;
Observable.prototype.combineLatest = require('rxjs/add/operator/combineLatest');
Upvotes: 9