redux-model-tools
Helpers for Redux to reduce its boilerplate.
Using
Create namespaced constants:
// model.js; const constants = ; console; // 'POST/EDIT'
And use them to create the corresponding actions. An action creator will be created for each constant automatically:
// actions.js;;; const actions = // actions.edit(42) -> { type: 'POST/EDIT', payload: 42 }// actions.remove(42) -> { type: 'POST/REMOVE', payload: 42 }// actions.asyncPublish -> dispatch => {}
Make a getter for your state
Suppose you have a state like this:
yourReducer: foo: 'foo' bar: 'bar'
Then you can make a getter in your model like so:
; const get = ;
And use it in containers like so:
; { return ; // { foo: 'foo', bar: 'bar' }}