0

There is Higher Order Observable observable

const obs1 = interval(1000).pipe(take(5));
const obs2 = interval(500).pipe(take(2));
const obs3 = interval(2000).pipe(take(1));
//emit three observables
const source = of(obs1, obs2, obs3);

How to use concatMap in order to as soon as the previous observable is completed, the next one immediately begins. After it will return result array of Observable.Need to use concatMap.

1 Answer 1

3

You'll need to use toArray() to collect all emissions from all source Observables.

source.pipe(
  concatMap(observable => observable),
  toArray(),
);
Sign up to request clarification or add additional context in comments.

2 Comments

calling concatAll() instead of concatMap(observable => observable) seems prettier
Yes, but OP said he needs to use concatMap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.