rxjs

ConcatMap

ConcatMap

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

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.