Dynadux Store is the return of the createStore
read here for more and is an object with two props: state
getter and dispatch
function.
One.
If you come from Redux, in Redux, we have A Store with multiple States (root properties). In Dynadux, we have one Store, with one State, and the root props would be considered App's Section States.
It is the return of a function that wraps a Dynadux store. The return has getters and methods to be used by the application. These getters and methods are accessing the Dynadux store.
You develop business Stores. Dynadux is the state manager, the engine, of these stores.
The Business Stores concept introduced by Dynadux's approach in this repo.
Since v2.2.0 it has, checkout the react-dynadux.
Provider promotes one State Management that makes the app a monolithic.
On the other hand, it offers some nice features for small or large react applications
- Any component can be connected without pass the store directly
- Reduces the global renderings since it renders only the connected components
- No need to
forceUpdate()
onChange
With react-dynadux, there are some more benefits
- It "publishes" any App Store and not the state
- On component's connection, there is a callback to control the render according to the dispatched
action
&payload
reducers: {
[actions.LOGIN]: ({dispatch, payload: {name, psw} }) => {
loginUser(name, psw) // <- your async method
.then(info => dispatch(actions.LOGIN_SUCCESS))
.catch(error => dispatch(actions.LOGIN_DAILED, error));
},
},
Or in modern async
way
reducers: {
[actions.LOGIN]: ({dispatch, payload: {name, psw} }) => {
(async () => { // make an async closure to use the await
try {
await loginUser(name, psw);
dispatch(actions.LOGIN_SUCCESS);
} catch(error) {
dispatch(actions.LOGIN_DAILED, error);
}
})();
},
},
_Personal preference the ().then().catch()
pattern looks simpler!…
- React How to use it in react
- Examples Live examples. Examples compared to redux's implementations
- Sections Create sections for applications or big components
- Advanced Dispached promises, boost up your app and more
- Typescript Tips for Typescript implementations
- Terminology Terminology of dynadux, (is small!)
- History, Undo/Redo Middleware for History, Undo/Redo and Restore Points
- React Dynadux Provider for Dynadux App Stores
- Change Log Changes of Dynadux per semver version
- 🏠 Home, Contents