ConcatMap Operator - RXJS

ConcatMap Operator - RXJS

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

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

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.

You might also like

Leave a Comment