Skip to content

Instantly share code, notes, and snippets.

@ConnorRigby
Created September 19, 2016 18:22
Show Gist options
  • Save ConnorRigby/f12c95ee7065aefc399375c60413ea3c to your computer and use it in GitHub Desktop.
Save ConnorRigby/f12c95ee7065aefc399375c60413ea3c to your computer and use it in GitHub Desktop.
// This is usefull for checking unused reducer functions.
const uselessReducerDetector = storeObj => next => action => {
let result = next(action);
let state1 = storeObj.getState();
let state2 = reducers(state1, result);
let isEqual = JSON.stringify(state1) === JSON.stringify(state2);
if (isEqual && action.type[0] !== "@") {
console.warn(`${action.type} didn't change state. May or may not be useless.`);
} else {
return result;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment