0

I have a component that makes some http requests and send the responses to another component. Currently, I'm using Observables and Subjects, every resquest is added in the subject and returns an Observable, and then I subscribe this observable and emit its response. Can someone tell me how to send the responses only after all the requests completes?

Here is a exemple of what I am doing.

requestLine.next(search);

observable = requestLine.mergeMap(search => {
  return service.getSearh(search)
})

observable.subscribe(res => {
  emitter.next(res);
});

Tks

  • you probably need to chain up the subscriptions to one another, could you please post some of your code, so that I can illustrate. – S_developer Aug 17 '17 at 20:29
  • You may want to take a look at this : https://xgrommx.github.io/rx-book/content/getting_started_with_rxjs/creating_and_querying_observable_sequences/creating_and_subscribing_to_simple_observable_sequences.html – Antoine Boisier-Michaud Aug 17 '17 at 20:32
  • Possible duplicate of [RXJS Wait for all observables in an array to complete (or error)](https://stackoverflow.com/questions/41734921/rxjs-wait-for-all-observables-in-an-array-to-complete-or-error) – yms Aug 17 '17 at 20:34
  • See if this helps: https://www.learnrxjs.io/operators/combination/forkjoin.html – yms Aug 17 '17 at 20:35
  • @S_developer I've added to the problem description, tks – Ana Claudia de Freitas Aug 17 '17 at 20:37
  • We'd need a bit more code than this to give a meaningful answer – Ced Aug 17 '17 at 21:48

0 Answers0