2

With the following piece of code (taken from an @Effect() in ngrx/store)

.switchMap(({token, param1, param2}) => {
  return Observable.combineLatest(
    this.service.getData2(token, param1),
    this.service.getData2(token, param2),
    this.service.getData3(token),
  );
})

What would be the most succinct yet correct pattern to catch the errors? Should the .catch follow every getData* call? We don't want .catch() at the end of the main @Effect() chain, do we?

The question is similar to this one, yet a bit different in that I don't a .subscribe() call here.

Community
  • 1
  • 1
user776686
  • 7,933
  • 14
  • 71
  • 124

1 Answers1

4

This totally depends on the desired behaviour. Lets asume you are fetching 3 animals which you will display. What do you want to happen when one fail?

  • Do not display any animal. -> add a catch to the end
  • Display the other animals. -> add catch to each data call.
Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116