Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby reducer example
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
You can’t perform that action at this time.