MdlFlux implements unidirectional flow in contrast to popular frameworks such as Angular or Ember. Even though two-directional bindings can be convenient, they come with a cost. It can be hard to deduce what's going on and why.
When we trigger the action, the dispatcher will get notified. The dispatcher will be able to deal with possible store dependencies. It is possible that certain action needs to happen before another. Dispatcher allows us to achieve this.
At the simplest level, actions can just pass the message to dispatcher as is. They can also trigger asynchronous queries and hit dispatcher based on the result eventually. This allows us to deal with received data and possible errors.
Once the dispatcher has dealt with the action, stores that are listening to it get triggered. As a result, it will be able to update its internal state. After doing this it will notify possible listeners of the new state.
This completes the basic unidirectional, yet linear, process flow of MdlFlux. Usually, though, the unidirectional process has a cyclical flow and it doesn't necessarily end. The following diagram illustrates a more common flow.
It is the same idea again, but with the addition of a returning cycle. Eventually the components depending our our store data become refreshed through this looping process.
More infos about flux:
- Simples form of an Action [...]
- Main-Class for sending Actions
- Implements the ActionBus-interface via Streams ActionBus is registered by default for DI [...]
- Strong-Typed ActionName [...]
- This Action carries a data-package [...]
- The DataStores are responsible for managing business logic and data. [...]
T extends Action>
- Received by a concrete implementation of DataStore if something has changed in the DataStore
- The Dispatcher is the central hub that manages all data flow in a MDL(Flux) application. [...]
- This is the base class for DataStore so it's not really a DataStore but if you need an object that informs others about an internat change-state the Emitter can help you [...]
- Fire-Only DataStore [...]
- Marker for all objects that can be deserialize from Json
T extends ToJson>
- This Action carries a special data-package. The data-package can be serialized to JSON [...]
- Marker for all objects that can be serialized and deserialize from Json
- Marker for all objects that can be serialized to Json
T extends ToJson>
- Creates a JSON-Map [...]
- Stock-Action that is emitted by the Dispatcher.emitChange-Function