duckfactory
Advanced tools
Comparing version 1.2.4 to 1.2.5
{ | ||
"name": "duckfactory", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "Factory for creating redux ducks", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# Duckfactory | ||
##### Simple creation and use redux ducks. | ||
**Simple creation and use of redux ducks.** | ||
### Why? | ||
<a href="https://github.com/reactjs/redux">Redux</a> / <a href="https://github.com/reactjs/react-redux">react redux</a> are great, but can produce a lot of boilerplate and fragmented code as a project grows, even for simple functionality. | ||
[Redux](https://github.com/reactjs/redux) / [react redux](https://github.com/reactjs/react-redux) are great, | ||
but can produce a lot of boilerplate and fragmented code as a project grows, even for simple functionality. | ||
I really like the concept of <a href="https://github.com/erikras/ducks-modular-redux">redux ducks</a>, it aims to simplify and structure this: bundle the reducers with the actions that trigger them when they belong together - which they do most of the time. | ||
I really like the concept of [redux ducks](https://github.com/erikras/ducks-modular-redux), | ||
as it aims to simplify and structure this: | ||
Bundle the reducers with the actions that trigger them when they belong together - which they do most of the time. | ||
Duckfactory tries to make it as easy as possible to create ducks and add functionality to a project if necessary, while keeping the project code minimal, clean and readable. | ||
Duckfactory tries to make it as easy as possible to create ducks and add functionality to a project if necessary, | ||
while keeping the project code minimal, clean and readable. | ||
### Where? | ||
## Installation | ||
``` | ||
npm install duckfactory --save | ||
``` | ||
or | ||
``` | ||
yarn add duckfactory | ||
``` | ||
##### npm install duckfactory | ||
...or | ||
##### yarn add duckfactory | ||
## How does it work? | ||
Give it a prefix string to group the actions, an initial state, an object with the names of action creators | ||
and the reducers the actions should trigger. | ||
It will then create an object that exposes ordinary redux action creators, reducers and action types. | ||
### How? | ||
Give it a prefix string to group the actions, an initial state, an object with the names of action creators and the reducers the actions should trigger. And it will create an object that exposes ordinary redux action creators, reducers and action types: | ||
#### Constructor arguments: | ||
### Constructor arguments: | ||
- _actionTypePrefix_: a prefix string added before each action creator name, to produce the action type strings. Should be globally unique if you use more than one duckfactory (and/or <a href="https://github.com/espen42/goosefactory">goosefactory</a>). If empty or missing, no prefix will be added and the actioncreator names will be used as action types - then it's up to you to ensure your action types become unique. | ||
@@ -31,4 +37,3 @@ - _initialState_: the reducer's initial state (for the state subtree that the duck should cover), | ||
#### Exposed after creation: | ||
### Exposed after creation: | ||
After creation, the resulting duck exports as JS objects: | ||
@@ -43,9 +48,10 @@ - _.getActionCreators()_: actionCreator-name → actionCreator-function | ||
#### Examples | ||
## Examples | ||
...coming soon. Until then, take a look at _src/duckfactory_spec.js_ | ||
### Used with redux-sagas | ||
## Used with redux-sagas | ||
The produced actions can of course be used to trigger redux sagas too. But to make this part even easier, take a look at <a href="https://github.com/espen42/goosefactory">Goosefactory</a> - a sibling library made for redux-sagas instead of reducers. Duckfactories and Goosefactories work nicely with each other. | ||
The produced actions can of course be used to trigger redux sagas too. | ||
But to make this part even easier, take a look at [Goosefactory](https://github.com/espen42/goosefactory) — a sibling | ||
library made for redux-sagas instead of reducers. Duckfactories and Goosefactories work nicely with each other. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56
17033