redux-saga-models
Models layer backed with redux-saga.
Library is NOT ready for production yet.
Installation
npm install --save redux-saga-models
Features
- Sagas to handle dispatched actions
- Mixins (see example of mixin in
mininx/crud
andtest/crud.specs.js
) - Grouping models (see
test/index.specs.js
--create models
) - Dispatch actions from any place of application (thanks to machadogj for idea)
Simple usage
Defining a model:
models/user.js
; const user = ; ;const reducer sagas selectors = user;
And we create follwing artifacts:
reducer
-- model's reducer.
sagas
-- array of created sagas.
selectors
-- methods that returns current model state.
For example, after calling user.findById('me')
you can receive data like this:
const result fetching fetched = userselectors;
Using newly created model in submit handler:
containers/LoginForm.js
;;;; const mapDispatchToProps = { user }; const LoginFormContainer = LoginForm;;
Also you can define custom reducer and selectors:
models/user.js
const user = ;
See more examples and configuration ways in tests.
Roadmap
- Make a simpler interface for creating models
- Write README
- Add example projects
- Use isomorphic-fetch as default fetch in
helpers/api
andmixins/crud
- 100% tests code coverage
- ...
Work in progress...