Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created April 13, 2016 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/9c4dbdfd604547d32d4a9243eecffb93 to your computer and use it in GitHub Desktop.
Save chuck0523/9c4dbdfd604547d32d4a9243eecffb93 to your computer and use it in GitHub Desktop.
type Action = Add
| InputText String -- New!
update : Action -> Model -> Model
update action model =
case action of
Add ->
let newTodo = ( model.nextID, Todo.init model.addText )
newTodos = model.todos ++ [ newTodo ]
in
{ model |
todos = newTodos,
nextID = model.nextID + 1
}
InputText str -> -- New!
{ model |
addText = str
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment