Observable.zip is not a function

KarolDepka picture KarolDepka · May 16, 2017 · Viewed 10.5k times · Source

VM95422:27 ORIGINAL EXCEPTION: WEBPACK_IMPORTED_MODULE_3_rxjs_Observable.Observable.zip is not a function

Tried various imports

// import 'rxjs/add/operator/zip';
// import 'rxjs/add/observable/zip-static';
// import 'rxjs/add/operator/zip';
import 'rxjs/operator/zip';

Trying to use it like that:

const zippedUsers: Observable<User[]> = Observable.zip<User>(this.usersObservable);

Angular 4, TypeScript 2.1.6

package.json:

"rxjs": "^5.1.0",

Answer

Patrioticcow picture Patrioticcow · Sep 21, 2017

maybe something like

import {Observable} from "rxjs/Observable";
import "rxjs/add/observable/zip";

then something like:

Observable.zip(this.someProvider.getA(), this.someProvider.getB())
        .subscribe(([a, b]) => {
            console.log(a);
            console.log(b);
        });