Created
January 27, 2018 18:14
-
-
Save strzibny/f45550cdc24b5e44c37a5c5eb35dfdac to your computer and use it in GitHub Desktop.
Example todo reducer
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
todos_reducer = -> (state, action) { | |
state ||= [] | |
case action[:type] | |
when 'add' | |
state.push(action[:todo]) | |
when 'remove' | |
state.remove(action[:todo]) | |
else | |
state | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment