duxegg

0.0.8 • Public • Published

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

npm version
Build Status
NPM

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
}

Readme

Keywords

Package Sidebar

Install

npm i duxegg

Weekly Downloads

1

Version

0.0.8

License

MIT

Unpacked Size

25.1 kB

Total Files

28

Last publish

Collaborators

  • brianneisler