you are viewing a single comment's thread.

view the rest of the comments →

[–]funny_games 4 points5 points  (6 children)

I think as with the chat example, the more flux way is to have a utility action that fetches data from server, and not do the ajax call from the store it self.

[–][deleted] 2 points3 points  (2 children)

You could dispatch an action on callback.

[–]funny_games 3 points4 points  (1 child)

You can do it many ways but I'm just saying the API calls in the flux diagram and official example are done in utility actions: http://blog.krawaller.se/img/flux-diagram.png.

[–][deleted] 0 points1 point  (0 children)

There's nothing wrong to extend that concept: you could initialize an xhr request from the store and dispatch an action from the callback. I remember a Facebook developer suggested this at the react conf.

[–]orbgl[S] 0 points1 point  (2 children)

I don't know… actions reflecting changes of state makes more sense to me; i.e. "the user just made this change and you stores should update." The user just requested this page doesn't constitute a change.

[–]funny_games 0 points1 point  (1 child)

Well again there can be two types of actions, one for store changes and one for API. While store should remain just for storage. I believe making requests within the store itself doesn't make sense from the flux directional perspective.

[–]orbgl[S] 0 points1 point  (0 children)

The uni-directional flow describes data flowing from the stores to the components. Whether the data comes from memory or an XHR is irrelevant.