Created
November 25, 2018 23:03
-
-
Save vitto-moz/49e017df4dca6b7964f7aafe41b6c20e to your computer and use it in GitHub Desktop.
ReducerLookUp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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