Skip to content

Instantly share code, notes, and snippets.

@strzibny
Created January 27, 2018 18:14
Show Gist options
  • Save strzibny/f45550cdc24b5e44c37a5c5eb35dfdac to your computer and use it in GitHub Desktop.
Save strzibny/f45550cdc24b5e44c37a5c5eb35dfdac to your computer and use it in GitHub Desktop.
Example todo reducer
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