grea
v0.0.2
Published
An opinionated redux's reducers & actions code generator.
Downloads
4
Maintainers
Readme
grea
An opinionated redux's reducers & actions code generator.
Requirements
- Node > v10
Quick Start
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.
Generated Codes
Actions
- Full upper case for action names.
- camelCase action creators.
Reducers
- 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.
Commands
yarn execute
- Run the generator.yarn test
- Run Jest tests.
License
MIT