0.0.0-alpha.1 • Published 6 years ago
deltadux v0.0.0-alpha.1
DeltaDux
Description
Helper methods and cli to remove the boilerplate of Redux project setup and development.
Setup
npm install deltadux --save
cd <src directory>
deltadux create
Usage
- Create Actions
// ./store/actions/counter.js
import { createAction as ca } from "deltadux"
export const inc = ca("INCREMENT")
export const dec = ca("DECREMENT")
Create Reducer
deltadux reducer counter
// ./store/reducers/counter.js
import { createReducer as cr } from "deltadux"
import { inc, dec } from "../actions/counter"
export default cr({ count: 0 }, [
inc.case(({ count }, v = 1) => ({ count: count + v })),
dec.case(({ count }, v = 1) => ({ count: count - v }))
])
- Dispatch Actions
// ./components/counter.js
import { connect } from "react-redux"
import { inc, dec } from "../store/actions/counter"
export default connect(
({ counter }) => ({ counter }),
dispatch => ({
inc () {
dispatch(inc())
},
dec () {
dispatch(dec())
}
})
)
Example
0.0.0-alpha.1
6 years ago