0.0.0-alpha.1 • Published 6 years ago

deltadux v0.0.0-alpha.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

DeltaDux

Description

Helper methods and cli to remove the boilerplate of Redux project setup and development.

Setup

  1. npm install deltadux --save
  2. cd <src directory>
  3. deltadux create

Usage

  1. Create Actions
// ./store/actions/counter.js
import { createAction as ca } from "deltadux"

export const inc = ca("INCREMENT")
export const dec = ca("DECREMENT")
  1. 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 }))
])
  1. 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