Skip to content

Instantly share code, notes, and snippets.

@vitto-moz
Created November 25, 2018 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitto-moz/49e017df4dca6b7964f7aafe41b6c20e to your computer and use it in GitHub Desktop.
Save vitto-moz/49e017df4dca6b7964f7aafe41b6c20e to your computer and use it in GitHub Desktop.
ReducerLookUp
export interface ReducerLookUp<T> {
[key: string]: (state: T, action) => T
}
export function lookUpMatcher<T>(lookUp: ReducerLookUp<T>, state: T, action: Action): T {
return lookUp[action.type] ?
lookUp[action.type](state, action) :
state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment