namespace-constants
Add namespace to Redux action type constants without name conflicts.
Installation
npm install --save namespace-constants
Examples
Global Constants
import constants from 'namespace-constants';
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants([
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
]);
Namespace Constants
import constants from 'namespace-constants';
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
]);
Mixing with string and object types
const result = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO',
{
FETCH: ['REQUEST', 'SUCCESS', 'FAILURE'],
EXPORT: 'REQUEST'
}
]);
Use a custom separator
export const {
ADD_TODO,
REMOVE_TODO,
TOGGLE_TODO
} = constants('ns', [
'ADD_TODO',
'REMOVE_TODO',
'TOGGLE_TODO'
], { separator: '/' });
License
MIT