Three ReactJS and Flux commandments
kriswallsmith.net
kriswallsmith.net
Original comment:
I'm not sure I agree with the first point. Let's say your store's HTTP requests fails and you want to inform the user (through the view component). You want to listen to yet another event from the same store to catch this? An alternative is to do exactly what you say you shouldn't do in step 1; basically have a "loadDataAction" that you fire off when your component gets mounted, using some unique id or something. Prior to this action, the store will return whatever it has (synchronously, similar to what you describe). The action then handles the HTTP request. If it succeeds, it updates the store, and the listener will get the updated data (yes, I agree, the component should always have a listener to the store). If it fails, the same "loadDataAction" will fire off a "showMessageAction" which also alters some store that your component listens to that will display the error message. Typically this would be caught by some higher-up global "show message" component. Like most people, I'm pretty new to a lot of this as well, but I have found that trying to keep most async stuff in the actions works a lot better than async everywhere. YMMV.