https://github.com/diegohaz/redux-modules
A modular approach to better organize redux stuff (not another library)
https://github.com/diegohaz/redux-modules
normalizr redux redux-architecture redux-saga
Last synced: about 1 month ago
JSON representation
A modular approach to better organize redux stuff (not another library)
- Host: GitHub
- URL: https://github.com/diegohaz/redux-modules
- Owner: diegohaz
- License: mit
- Created: 2017-02-18T08:45:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-15T02:40:28.000Z (almost 8 years ago)
- Last Synced: 2024-05-01T23:15:53.116Z (about 1 year ago)
- Topics: normalizr, redux, redux-architecture, redux-saga
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 21
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redux-modules
[](https://travis-ci.org/diegohaz/redux-modules) [](https://codecov.io/gh/diegohaz/redux-modules/branch/master)
This is a modular approach to better organize redux stuff. It was inspired by [ducks-modular-redux](https://github.com/erikras/ducks-modular-redux). However, this handles not only `actions` and `reducers`, but also `selectors`, `sagas`, `middlewares` etc.
In short, a redux module is:
- **A feature** with action creators, reducer, selectors, sagas, middlewares and any other thing from the redux ecosystem (see [`examples`](examples));
- **Complete**, which means that one feature will not be separated into multiple modules;
- **Pluggable**, which means that you can always add or remove it to have or not that feature without having to change other redux modules.
## The problem
Let's say you have an existing project with a bunch of redux entities, such as `articles`, `users` and `comments`, with their own reducers and selectors, as well as action creators or sagas to perform CRUD operations (see [`examples/resource`](examples/resource)).
Now you want to add [normalizr](https://github.com/paularmstrong/normalizr) to it. Then you realize that you'll need to do a lot of refactor to proper `normalize` and `denormalize` your entities.
The problem gets even worse if after some time your team decides to remove normalizr. You'll need to refactor everything again.

## The solution
A redux module would take care of and encapsulate the normalization feature (see [`examples/entities`](examples/entities)).
You'll just need to change your containers to use selectors from the `entities` module instead of the `articles`, `users` and `comments` ones.

## License
MIT © [Diego Haz](https://github.com/diegohaz)