https://github.com/brianneisler/duxtape
Module and utility framework for redux
https://github.com/brianneisler/duxtape
Last synced: about 5 hours ago
JSON representation
Module and utility framework for redux
- Host: GitHub
- URL: https://github.com/brianneisler/duxtape
- Owner: brianneisler
- License: mit
- Created: 2016-09-02T16:41:40.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T00:21:57.000Z (about 8 years ago)
- Last Synced: 2025-05-28T23:48:59.919Z (21 days ago)
- Language: JavaScript
- Homepage: http://duxtape.org
- Size: 44.9 KB
- Stars: 16
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# duxtape
*"You can never have enough duxtape for redux."*Module and util framework for redux.
## Benefits
- Utility methods packaged under one roof for easily building out redux functionality
- Introduces an abstract module construct for redux. Allows modularization of functionality and easy plug and play workflow
- Hook system for extending the functionality of redux
- Provides a framework for building out an entire application (if desired)## Build Status
[](https://badge.fury.io/js/duxtape)
[](https://travis-ci.org/brianneisler/duxtape)
[](https://nodei.co/npm/duxtape/)## Documentation
[Full API documentation](docs/API.md) - Learn about each method
## Install
```bash
npm install --save duxtape
```## Usage
```js
import o from 'duxtape'
import { reducer } from 'duxtape/modules'const { decrement, increment } = o.createActions({
DECREMENT: amount => amount,
INCREMENT: amount => amount
})const build = o.compose(
o.setName('inc'), // sets base state path to 'inc'
o.withActions({
decrement,
increment
}),
o.defaultState({
counter: 0
}),
o.withReducer(() => o.handleActions({
DECREMENT: (state, action) => ({
counter: state.counter - action.payload
}),
INCREMENT: (state, action) => ({
counter: state.counter + action.payload
})
}),
o.withHooks({
init: (state) => console.log('module initialized'),
receiveState: (nextState, state) => console.log('module state received:', nextState)
})
)const module = build()
// Order of modules matters, they will be processed in order given
const store = o.createStore([
reducer,
module
])// listen for state changes on all of store
store.subscribe((state) => {
console.log('store state changed')
console.log('store state:', state)
})// listen for state changes on module
module.subscribe((state) => {
console.log('module state changed')
console.log('module state:', state)
})// old school dispatch
store.dispatch({ type: 'INCREMENT', payload: 1 })// dispatch with action creator
store.dispatch(increment(2))// dispatch via module
module.decrement(3)// get store state
console.log(store.getState())// get module state
console.log(module.getState())
```