actiontypes
A simple utility to generate namespaced strings for Flux standard actions.
Usage
actionTypes(namespace, type1, [type2, ...] [, options])
actionTypes(namespace, typesArray, [, options])
Basic
import actionTypes from "actiontypes";
const actions = actionTypes("namespace", "HELLO", "THERE");
You’ll got:
console.log(actions);
{
HELLO: "namespace/HELLO",
THERE: "namespace/THERE"
}
More:
const actions = actionTypes(
"namespace",
"OPEN",
"CLOSE",
"close",
"tYPO",
);
console.log(actions);
{
OPEN: "namespace/OPEN",
CLOSE: "namespace/CLOSE",
TYPO: "namespace/TYPO"
}
Array of types
Also an array of types strings as a second argument can be passed:
const actions = actionTypes("simple", ["HELLO", "THERE"]);
Configuration
import actionTypes from "actiontypes";
const actions = actionTypes("namespace", "INIT", {
prefix: "@@",
delimeter: "--",
}
);
And you’ll got:
console.log(actions);
{
INIT: "@@namespace--INIT"
}