JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q51049F
  • License MIT

Faster and nicer reducers for your Redux applications. Say "NO!" to switch statements!

Package Exports

  • redux-blower

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-blower) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Code Climate Test Coverage Issue Count Dependency Status

redux-blower

redux-blower is a tiny library that helps you to improve the readability and the performance of your Redux applications.

⚠️ Caution Still work in progress. Library will be finished in next couple of days!

How?

Typical Redux application has couple of reducers which are usually functions with big switch statements. When an action is triggered, Redux is going through ALL reducers, ALL switch statements and ALL cases in order to decide if something should happen. Imagine that you have a Redux application with 100 reducers of average 5 case callbacks. That would mean that for each triggered action up to 500 comparisons has to be made. Additionally reducers will most-likely end up as functions with high complexity and they are not easy to read. Now let me show you what redux-blower can do!

const actions = [
  'counter:INCREMENT',
  'counter:DECREMENT'
];

const [inc, dec] = actions;

const reducer = createReducer({
  initialState: 0,
  listenTo: actions,
  [inc]() {
    return this.state + action.payload;
  },
  [dec](state, action) {
    return state - action;
  }
});

reducer(0, { type: 'counter:INCREMENT', payload: 2 }); // => 2
reducer(5, { type: 'counter:DECREMENT', payload: 5 }); // => 0

In the previous example the counterReducer will only react to action that belongs to counter group. If an action of different type is fired, then only one comparison will be done for counterReducer.

All is working as expected

License

The MIT License (MIT) - See file 'LICENSE' in this project

Copyright © 2016 Jiri Chara. All Rights Reserved.