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.

1 Answer 1

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.
Sign up to request clarification or add additional context in comments.

Comments

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.