Daux
An immutable model-based state management solution for your JavaScript apps.
Design
The library was built by combining some of the concepts of Ember Data and Redux.
Most apps have a model-based state that might look like this:
In Daux, these kind of states are managed by the Store
. With it, you'll be able to create, read, update, and delete model records.
Installation
Assuming that you're using npm as your package manager:
npm install daux
If you're not using any module bundler, you can use the precompiled production and development UMD builds in the dist
folder. For this build, Daux
would be available as a window.Daux
global variable. You can download the files at unpkg.
Usage
Check out the API reference
Setup your models
Create your models
; static { return 'name'; } static { return country: type: 'country' kind: 'belongsTo' inverse: null groups: type: 'group' kind: 'hasMany' inverse: 'members' posts: type: 'post' kind: 'hasMany' inverse: 'author' ; } /** * Optional hook to deserialize a record */ static { const deserializedRecord = {}; Object; return deserializedRecord; }
Next, we pass-in those models to the Store
:
const store = user: User;
Fetching states
{ return store;}
Changing states
{ await ; store;}
Subscribing to state changes
// Log "Foo" everytime a state changesconst unsubscribe = store; // Stop listening to state changes;
Contributing
Installation
git clone <repository-url>
cd daux
npm install
Running tests
npm test
License
This project is licensed under the MIT License.