The Deprecation Notice

You have likely encountered code that looks like this across numerous tutorials and examples.

forkJoin(
  of(1, 2),
  of(A, B),
)
Enter fullscreen mode Exit fullscreen mode

While this code functions correctly today, it is relying on a deprecated API that will no longer be available when RxJS v8 arrives.

Per the official documentation, directly supplying Observables as individual arguments is now deprecated.
This pattern, known as the rest-parameter signature, is scheduled for removal in RxJS v8.

The RxJS team recommends passing an array of sources as the argument instead, as demonstrated here.

const sources = [of(1, 2), of(A, B)]
forkJoin(sources)
Enter fullscreen mode Exit fullscreen mode

For a more complete example, check out the piece on How To Use ForkJoin - Angular Example (free article). A quick preview is shown below:

sources = [
    this.http.get('https://.../users/1'),
    this.http.get('https://.../users/2'),
    this.http.get('https://.../users/3'),
  ];

  constructor(private http: HttpClient) {}

  ngOnInit() {
    forkJoin(this.sources).subscribe(console.log);
  }

Enter fullscreen mode Exit fullscreen mode

You can also experiment with this implementation on StackBlitz.

Useful Information

For those working with RxJS who haven't yet discovered the Operator Decision Tree, it is worth a look. This tool assists you in choosing the most appropriate operator for your specific scenario.

RxJS Operator Decision Tree