Skip to content
Advertisement

how to run subscribe sequentially in observable

I want to run code sequentially but I was wondering how this works, for example, I have a method that includes two observable and some fields. I want to run the first observable completely then the next field values check and after that the last observable method:

JavaScript

but at the current stage step 2 completed first and step 3 next and at the end step 1. and sometimes it works fine. I read about concat here, I know this is a nice feature to get what I need but to be honest I couldn’t use it, and that only work if we have 2 observable over next each other(only step 3 and step 1).

Advertisement

Answer

There isn’t enough data to go around, but for a start you could use tap and switchMap operators. tap would be used for “step 2” and switchMap would be used to map to another observable (in your case “step 3”, the 2nd HTTP request).

Try the following

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement