Skip to content

A modular approach to better organize redux stuff (not another library)

License

Notifications You must be signed in to change notification settings

diegohaz/redux-modules

Repository files navigation

redux-modules

Build Status Coverage Status

This is a modular approach to better organize redux stuff. It was inspired by 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);
  • 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.

Plug

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).

Now you want to add 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.

So much work

The solution

A redux module would take care of and encapsulate the normalization feature (see 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.

Nice

License

MIT © Diego Haz

About

A modular approach to better organize redux stuff (not another library)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published