RxJS

Mon, 19 May 2025 12:54:24 GMT

 Properties

Key Value
Identifier rxjs
Name RxJS
Type Topic
Creation timestamp Mon, 19 May 2025 12:54:24 GMT
Modification timestamp Mon, 19 May 2025 12:55:59 GMT

To chain Observables where one request depends on the response of another, use the RxJS switchMap operator:

this.myService.fetchSomething().pipe(
  switchMap((something) => {
    return this.myOtherService.fetchSomethingElse(something);
  })
).subscribe(
  (somethingElse) => { ... }
);

To execute Observables in sequence when the requests are not dependent on each other's responses, use concatMap.

To execute Observables in parallel and return a collection of responses in the order that they finished, use mergeMap.

To execute Observables in parallel and preserve the order of responses, use forkJoin.

In most situations, you will want to use either switchMap or forkJoin.

Back to top

 Context

 Topic resources