0.0.0-alpha.7 • Published 6 years ago

deltax v0.0.0-alpha.7

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

DeltaX

Description

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

Setup

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

Usage

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

export const inc = ca("INCREMENT")
export const dec = ca("DECREMENT")
  1. Create Reducer

    deltax reducer counter

// ./store/reducers/counter.js
import { createReducer as cr } from "deltax"
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

0.0.0-alpha.7

6 years ago

0.0.0-alpha.6

6 years ago

0.0.0-alpha.5

6 years ago

0.0.0-alpha.4

6 years ago

0.0.0-alpha.3

6 years ago

0.0.0-alpha.2

6 years ago

0.0.0-alpha.1

6 years ago