2.0.0 • Published 5 years ago

redux-generate v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

redux-generate

Tiny library that generates actions out of your types

Install

yarn add redux-generate

or

npm i --save redux-generate

Usage

  • Create a folder, where your actions should be generated

  • Create a file "my-custom-action.js" in that folder, which should look kind of this:

import { generateActions, createActionTypes } from 'generate-actions'

const typeSliderList = [
  'HANDLE_STUFF',
  'DO_SOMETHING',
]

export const ActionTypes = createActionTypes(typeSliderList)

export const Actions = { ...generateActions(ActionTypes) 
}
  • Create folder for your reducers
  • Create a file: "my-custom-reducer.js", which should look like that:
import {generateReducers} from 'redux-generate-actions'
import { Actions } from '../actions/my-custom-actions.js'

export const reducers = {
  [Actions.HANDLE_STUFF](state, action) {
    ...
    return state
  },

  [Actions.DO_SOMETHING](state, action) {
  ...
    return {
      ...state,
    }
  },
}

export const sliders = generateReducers([], reducers)
2.0.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.0

5 years ago