Observable.zip is not a function

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",

Answers


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);
        });

RxJS 6

Starting from RxJS 6...

Observable creation functions

such 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'));
Pipeable operators

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 => ...);

5.5 rxjs:

import {zip} from "rxjs/observable/zip";
const zippedUsers: Observable<User[]> = zip(this.usersObservable);

Need Your Help

How to create a variable that can be set only once but isn't final in Java

java reference final

I want a class that I can create instances of with one variable unset (the id), then initialise this variable later, and have it immutable after initialisation. Effectively, I'd like a final variable

Create shortcut to desktop using WiX

wix installer windows-installer shortcut

So I have this setup project in Wix and wanted to have a shortcut on the desktop.