0

I have a react component - a page where users can create an application. When they click create, I make an async call. If the async call is successful then I let the dispatcher know about the action. Otherwise, if I receive an error, I don't inform the dispatcher and render some error text instead.

Is this how others would go about handling such a scenario? I think this is the right approach, but there is a part of me that thinks that the dispatcher should be handling the async call. However, I'm not sure how I would inform the view that an error has occurred. I could re-render the view and pass the error as a prop, but this approach seems like it's adding too much complexity.

Thanks!

BezR
  • 503
  • 1
  • 6
  • 12

1 Answers1

1

I was pointed to 2 other SO questions:

How do you manage asynchronous Store operations with Flux?

Should flux stores, or actions (or both) touch external services?

In short, your action-creator can make the async request, then dispatch the appropriate action: FAILED-REQUEST or COMPLETE-ADD-APPLICATION

The FAILED-REQUEST action can update a store with the error, and your component can use that error.

Community
  • 1
  • 1
BezR
  • 503
  • 1
  • 6
  • 12