An open API service indexing awesome lists of open source software.

https://github.com/brianneisler/duxegg

Simple module concept for redux
https://github.com/brianneisler/duxegg

Last synced: 4 months ago
JSON representation

Simple module concept for redux

Awesome Lists containing this project

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

[![npm version](https://badge.fury.io/js/duxegg.svg)](https://badge.fury.io/js/duxegg)

[![Build Status](https://travis-ci.org/brianneisler/duxegg.svg)](https://travis-ci.org/brianneisler/duxegg)

[![NPM](https://nodei.co/npm/duxegg.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/duxegg/)

## Install

```bash
npm install --save duxegg
```

## Usage

```js
// 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 = () =>

...

export default App
```

```js
// modules/index.js
import * from 'foo'
export {
foo
}
```

```js
// 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
}
```