Last active
January 27, 2018 18:32
-
-
Save strzibny/0d092c10502c89b6320fc801a22f4b8b to your computer and use it in GitHub Desktop.
Ruby reducer example
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
counter_reducer = -> (state, action) { | |
state ||= 0 | |
case action[:type] | |
when 'increment' | |
state += 1 | |
when 'decrement' | |
state -= 1 | |
else | |
state | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment