redux-action-type-factory
Simple tool to create redux action type list with minimal coding, but fully autocomplete/intellisense support
Installation
npm i redux-action-type-factory
or
yarn add redux-action-type-factory
This relies on typescript
for intellisense to run.
Usage
actionTypesFactory
-
actionTypesFactory
accepts first argument as the prefix, if this is empty string then there will be no prefix, the remaining arguments will be the action types. -
Each defined actionType has five members, with
default
is the action type itself, four others will append a suffix accordingly:
default
:${ACTION}
begin
:${ACTION}_BEGIN
succeeded
:${ACTION}_SUCCEEDED
failed
:${ACTION}_FAILED
cancelled
:${ACTION}_CANCELLED
Use them as following:
; let actionType = ; actionTypeINCREMENTdefault; // 'todo/INCREMENT'actionTypeINCREMENTbegin; // 'todo/INCREMENT_BEGIN'actionTypeINCREMENTsucceeded; // 'todo/INCREMENT_SUCCEEDED'actionTypeINCREMENTfailed; // 'todo/INCREMENT_FAILED'actionTypeINCREMENTcancelled; // 'todo/INCREMENT_CANCELLED' actionTypeDECREMENTdefault; // 'todo/DECREMENT'actionTypeDECREMENTbegin; // 'todo/DECREMENT_BEGIN'actionTypeDECREMENTsucceeded; // 'todo/DECREMENT_SUCCEEDED'actionTypeDECREMENTfailed; // 'todo/DECREMENT_FAILED'actionTypeDECREMENTcancelled; // 'todo/DECREMENT_CANCELLED' // or let actionType = ; actionTypeENDdefault; // 'END'actionTypeENDbegin; // 'END_BEGIN'actionTypeENDsucceeded; // 'END_SUCCEEDED'actionTypeENDfailed; // 'END_FAILED'actionTypeENDcancelled; // 'END_CANCELLED'
dictionaryFactory
- For those who just want to make a string dictionary, use this.
dictionaryFactory
accepts a list of string argument, return an object with the according key-value pair.
; let platforms = ; platformsandroid; // 'android'platformsios; // 'ios'platformsweb; // 'web'platformsdesktop; // 'desktop'
And this is fully supported by VS Code intellisense!