1.0.2 • Published 5 years ago

mudkib v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Action Generator

Trying to avoid collisions of actions using react-redux

/// actionTypes.js
import { generate } from "action-generator"

export const actionTypes = {
    INCREMENT: generate("INCREMENT"),
}

/// actions.js
import { actionTypes } from "./actionTypes";

export const increment = () => {
    return {
        type: actionTypes.INCREMENT,
    }
}

/// reducer.js
import { actionTypes } from "actionTypes"
...
switch (type) {
    case actionTypes.INCREMENT: {
        return state + 1
    }
}