I would be suspicious of using delays to give components enough time "to process the data between the api calls". You usually do not know how much time it takes to process the data so you may end up giving too much or too little time.
You should try to see if you can use more of rxjs idiomatic style. What I mean is the following.
Let's assume you have a function processDataBetweenAPICalls(data) which synchronously process the data received from an API call before calling the following API. In this case you could try something like this
from(Object.keys(someObj)) .pipe( concatMap(key => this.getUsers(key)), tap(res => processDataBetweenAPICalls(res) ) .subscribe(res => ...)
If instead the processing of the data between 2 API calls is not synchronous but rather is an async process, then I would try to turn this processing into an Observable, in other words I would try to create a function processDataBetweenAPICallsObs(data): Observable<any>. In this case the code could look like
from(Object.keys(someObj)) .pipe( concatMap(key => this.getUsers(key)), concatMap(res => processDataBetweenAPICallsObs(res) ) .subscribe(res => ...)
Not knowing in more details your use case, the above suggestions may be not on target.
EDIT AFTER COMMENT STATING THAT PROCESSING IS SYNCHRONOUS
If the processing is synchronous, as for my understanding your goal should be:
- get a value from the stream of values generated by
from(Object.keys(someObj)) (or anything similar - call an API (
getUsers in this case) for each value of the upstream - do whatever synchronous processing you have to do for with the response returned from the API call
- only after the above processing is completed, move to the next value of the source stream and repeat steps 1, 2 and 3 until the source stream completes or somewhere an error occurs
If my understanding is correct, then a simple concatMap should do the work like in this example.
switchMapcancels out the previous http call. It doesn't work for me