I can no longer use forkjoin with rxjs 5.5.2

Recently, I decided to migrate a big project that has been created from scratch with the "Quick Start" of Angular to a version using Angular CLI 1.5.5. Right now, I'm fixing the different issues that arise and I can't get to fix this one.

I read that it was better to use lettable operators of rxjs, which I did and it works very well. However, I also have these lines of code:

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

...

let piecesGrouping$: Observable<IGroupedPiece[]>[] = deliveries.map(delivery => this._pieceService.getGroupedPieces(delivery.pieces));

Observable
  .forkJoin(...piecesGrouping$)
  .subscribe((groups) => {
    groups.forEach((group, i) => deliveries[i].groupedPieces = group);

    resolve();
  });

They were working very well in the previous version that was using rxjs 5.4.3, now with rxjs 5.5.2, they don't anymore and I get the following error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'apply' of undefined TypeError: Cannot read property 'apply' of undefined

I tried to replace the spread operator by piecesGrouping$[0], piecesGrouping$[1] as the error does not say anything about forkJoin in itself, then I get:

ERROR Error: Uncaught (in promise): TypeError: WEBPACK_IMPORTED_MODULE_8_rxjs_Observable.a.forkJoin is not a function TypeError: WEBPACK_IMPORTED_MODULE_8_rxjs_Observable.a.forkJoin is not a function

So it looks like that I'm importing forkJoin the wrong way. I tried to import it from "rxjs/observable/forkJoin" but it didn't work either.

What am I missing?

Don't use Observable patching, use forkJoin directly:

import {forkJoin} from "rxjs/observable/forkJoin";

forkJoin(...piecesGrouping$).subscribe()

angular - I can no longer use forkjoin with rxjs 5.5.2, They were working very well in the previous version that was using rxjs 5.4.3, now with rxjs 5.5.2, they don't anymore and I get the following  Why use forkJoin? This operator is best used when you have a group of observables and only care about the final emitted value of each. One common use case for this is if you wish to issue multiple requests on page load (or some other event) and only want to take action when a response has been received for all.

You should be using it as a function

forkJoin(...piecesGrouping$)
  .subscribe((groups) => {
    groups.forEach((group, i) => deliveries[i].groupedPieces = group);

    resolve();
  });

import statement is changed as

import { forkJoin } from "rxjs/observable/forkJoin";

This was released as a part of 5.2 version . Read the change log

I can no longer use forkjoin with rxjs 5.5.2 - angular - html, Right now, I'm fixing the different issues that arise and I can't get to fix this one. I read that it was better to use lettable operators of rxjs, which I did and it works  Data storing can very often be moved directly to the observables passed to forkJoin as arguments. We could use the RxJS tap operator to handle We no longer have any data accessed by the array

RxJS 6.x uses this import

import {forkJoin} from 'rxjs';

As stated in the other answers, it still needs to be used as a function as it now stands on its own. Docs are here

forkJoin, This operator is best used when you have a group of any of the inner observables supplied to forkJoin error you will lose the value of any other observables that would or have already completed if you do not catch the error that if you have an observable that emits more than one item,  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Angular 6: Upgrading API calls to RxJS 6, Don't panic! There is a library called So your RxJS 5.x API calls and Observable methods will still work, for now. In fact, if you're using First, let's consider a service that uses forkJoin to make parallel API calls. The Angular  Meaning we can easily compose a bunch of pure function operators and pass them as a single operator to an observable! Conclusion. With those tools in hand, you can write RxJS code that is much more re-usable by just piping your (pure functions) operators together and easily re-use shared logic.

RxJS v5.x to v6 Update Guide, To refactor TypeScript code so that it doesn't depend on rxjs-compat, you can use rxjs-tslint . npm i -g rxjs-tslint Before RxJS release v7, you will need to remove and replace all use of deprecated functionality. forkJoin, ForkJoinObservable. Exports from a few places: rxjs common types, schedulers and utilities rxjs/create static creation methods like of, from, concat, forkJoin, fromEvent, etc rxjs/operators all of the pipeable operators rxjs/ajax the ajax implementation rxjs/websocket the web socket implementation Removes operator versions of observable creation helpers (use

forkJoin, That means forkJoin will not emit more than once and it will complete after that. If you need to Examples. Use forkJoin with a dictionary of observable inputs. Should navigate without errors, like with RxJS 5.5.2. Minimal reproduction of the problem with instructions. Run this Plunk. You can navigate between 2 pages without problems. Then edit the config.js file to make it load rxjs 5.5.3 instead of 5.5.2. Run the Plunk again.

Comments
  • @ssougnez, you're welcome. As I suggested, don't use patching imports. Use lettable operators for instance operators, and static operators directly.
  • Thanks Max,in my case, I am using ' import { forkJoin } from 'rxjs/Observable/forkJoin' which is wrong. please use 'import {forkJoin} from 'rxjs/observable/forkJoin' ( 'O' is small in Observable).
  • Thanks, it works, although I'll accept the answer of "AngularInDepth.com" as he also put the modified import line.