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",
5.5 rxjs:
import {zip} from "rxjs/observable/zip";
const zippedUsers: Observable<User[]> = zip(this.usersObservable);
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);
});
Starting from RxJS 6...
Observable
creation functionssuch as from()
, fromPromise()
, of()
, zip()
should be imported like this:
import { from, fromPromise, of, zip } from 'rxjs';
and used as a plain function call:
const data: Observable<any> = fromPromise(fetch('/api/endpoint'));
should be imported like this:
import { map, filter, scan } from 'rxjs/operators';
and used as pipe()
method arguments:
const someObservable: Observable<number> = ...;
const squareOddVals = someObservable.pipe(
filter((n: number) => n % 2 !== 0),
map(n => n * n))
.subscribe((n: number): void => ...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With