An opinionated redux's reducers & actions code generator.
- Node > v10
Install the package.
npm install grea --save-dev
Define actions to use in the desired output folder in yml format.
# Your action name will be prefixed with this.
prefix: ABC/DEF
# Define all your action name, and parameters expected.
actions:
- init
# Action prefixed with specific keywords will perform some special logics.
# - setXXX -> Sets the parameter value in reducer.
# - incrementXXX -> Increase the parameter value by 1 in reducer.
# - decrementXXX -> Decrease the parameter value by 1 in reducer.
- setUser:
- name: string # string, number, object, array
- ranking: number
Generate the code!
./node_modules/.bin/grea "YOUR_YML_PATH"
You should see a file ymlFileNameDucks.gen.js
created in the same folder with input yml with generated codes.
You can then import the actions, action creators and reducer (exported default) to use it.
PS: This generator is rerunnable, so you can run the same command after you have made changes to the action declaration file.
- Full upper case for action names.
- camelCase action creators.
- The initial state of reducer will be derived from the declaration file and set to a default value.
-
''
for string. -
0
for number. -
null
for object. -
[]
for array.
-
-
yarn execute
- Run the generator. -
yarn test
- Run Jest tests.
MIT