Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

action-types

es6js-standard-styleCircleCI

Conveniently create action types with multi-level namespace support.

A note about compatibility

The npm package should be used in an ES6 environment. Even though the published code has ES5 syntax it uses some ES6 features, so you have to make sure to use ES5 and ES6 polyfills if you are in an ancient environment.

Install

npm install action-types

Usage

import{ActionType,createActionTypes}from'./action-types'createActionTypes({START_APP: ActionType,user: {ADD: ActionType,REMOVE: ActionType,current: {SET: ActionType,CHANGE: ActionType}}})// results in:{START_APP: 'START_APP',user: {ADD: 'user.ADD',REMOVE: 'user.REMOVE',CHANGE: 'user.CHANGE',current: {SET: 'user.current.SET',CHANGE: 'user.current.CHANGE'}}}

With initial namespace

import{ActionType,createActionTypes}from'./action-types'createActionTypes({ADD: ActionType,REMOVE: ActionType},{namespace: 'user'})// results in:{ADD: 'user.ADD',REMOVE: 'user.REMOVE'}

With custom namespace separator

import{ActionType,createActionTypes}from'./action-types'createActionTypes({user: {ADD: ActionType,REMOVE: ActionType}},{separator: '::'})// results in:{user: {ADD: 'user::ADD',REMOVE: 'user::REMOVE'}}

Test

npm test

License

MIT

About

Conveniently create action types with multi-level namespace support.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages