A simple utility to generate namespaced strings for Flux standard actions.
actionTypes(namespace, type1, [type2, ...] [, options])
actionTypes(namespace, typesArray, [, options])
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", // Mandatory
"OPEN", // At least one string must be provided
"CLOSE",
"close", // Skips duplicates
"tYPO", // Forces uppercase
);
console.log(actions);
{
OPEN: "namespace/OPEN",
CLOSE: "namespace/CLOSE",
TYPO: "namespace/TYPO"
}
Also an array of types strings as a second argument can be passed:
const actions = actionTypes("simple", ["HELLO", "THERE"]);
import actionTypes from "actiontypes";
const actions = actionTypes("namespace", "INIT", {
prefix: "@@", // Optional. Prepends to all strings. Default is `""`, an empty string.
delimeter: "--", // Optional. Separator between namespace and short form. Default is `/`, a slash.
}
);
And you’ll got:
console.log(actions);
{
INIT: "@@namespace--INIT"
}