|
|
|
|
|
by grandalf
4173 days ago
|
|
A few questions: - What is the equivalent of the global action bus in Flux? - How do you handle consuming data from multiple rest endpoints? - Suppose you want to restructure the components in the app into a different hierarchy, how much refactoring is involved? - Is there any open source example code of an app built this way that is more complex than a simple todo or simple async example? (I think the biggest challenge with these kinds of apps comes at that next tier of complexity... it's trivial to do a clean TODO implementation that doesn't do anything with server data in nearly any framework). |
|
When a component needs data, it subscribes to the relevant stores, and updates itself on data changes.
When you want to mutate the data, you call an action, which in turns mutate the data in the store. Since the components are subscribed to stores, they get the new data automatically.
Stores subscribe to a central dispatcher, listening to all actions. When an action fires, they look the action's data, and mutate their data if it is relevant to them.
The data flow is action-> dispatcher-> store -> component -> action.
When you want to get data from a rest endpoint, you fire an action from the component. The action fetches the data, and pushes it to dispatcher.