In this tutorial, we will learn about the ConcatMap operator of RXJS.

concatMap Operator

ConcatMap is a  flatting operator

With using concatMap We no longer have to use nested subscribes with a higher-order mapping operator

With using concatMap male all HTTP request  to the backend sequentially

Example:

const source = from(["Tech", "Comedy", "News"]);

source.pipe(concatMap((res) => this.getData(res))).subscribe((res) => {
      console.log(res);
});

getData(data) {
   return of(data + " Video Uploaded").pipe(delay(2000));
}

Will Output:

Tech Video Uploaded
Comedy Video Uploaded
News Video Uploaded