ModulaJS
ModulaJS is created to provide an intuitive and simple way of manage complex state. It introduces Model (an immutable tree) to represent the application state tree. Both actions and reactions are handled inside Model, as well as the communications and side effects. It makes the components in view layer very simple, pure and stateless.
ModulaJS works perfectly with React, or any other view library, or vanilla JavaScript.
Influences
ModulaJS is inspired by Elm and Redux, and built upon redux. Most redux middlewares and the redux dev tools should work seamlessly with ModulaJS.
Installation
Prerequisites: Node.js (>=6.0), npm version 3+.
yarn add modulajs
Or use NPM
npm install --save modulajs
Documentation
Examples
Taking the counter example in redux, the following code implements a ModulaJS version.
The whole state is stored in Model tree of the single store, and the ONLY way to mutate a state is dispatching an action in model sender. The receiver, which handles the corresponding reaction, usually appear in pair of the sender, in the same Model class.
// counter_model.js;; const ActionTypes = ; const CounterModel = ; // app.js;; // Create a ModulaJS store to hold state in the decorated modelconst store = ; // Subscribe to store changing, then notify the listenersstore; // Bootstrap the state tree in root modelstore; // Dispatch an action with a model instance// This is the ONLY way to mutate a state in the Store.const getCounterModel = store; ;; // 1 ;; // 0
Contributing
Please read our contributing guide for details on how to contribute to our project.