duxegg
v0.0.8
Published
Simple module concept for redux
Downloads
2
Readme
duxegg
Simple module concept for redux
Benefits
- Simple module concept for abstracting redux dependencies from one another
- Modules are easy to compose together
- Simple hook system for tapping in to redux lifecycle
- Provides a framework for building out an entire application (if desired)
Build Status
Install
npm install --save duxegg
Usage
// app.js
import React from 'react'
import { Provider } from 'react-redux'
import { createStore } from 'duxegg'
import * as modules from './modules'
const config = {
foo: { // config passed to module is based on name of module
key: 'value'
}
}
const App = () =>
<Provider store={createStore(modules, config)}>
...
</Provider>
export default App
// modules/index.js
import * from 'foo'
export {
foo
}
// modules/foo/index.js
import { handleActions } from 'redux-actions'
import createSagaMiddleware from 'redux-saga'
const module = (config) => {
const middleware = createSagaMiddleware()
const reducer = handleActions({
...
})
const saga = function* saga() {
...
}
const run = (store) => {
// store is a redux store with an additional getModules method
const modules = store.getModules()
// do whatever you need to boot up this module or process some value from the other modules
}
return {
middleware,
reducer,
saga
}
}
export {
module
}