Skip to content

Instantly share code, notes, and snippets.

@odoe
Created December 7, 2015 17:31
Show Gist options
  • Select an option

  • Save odoe/f9ba1e03ef419a9a9d02 to your computer and use it in GitHub Desktop.

Select an option

Save odoe/f9ba1e03ef419a9a9d02 to your computer and use it in GitHub Desktop.
type Action = NoOp
| UpdateModel Model
| Selected String Bool
| ShowMap String Bool
update : Action -> Model -> Model
update action model =
case action of
NoOp ->
model
UpdateModel m ->
m
Selected id isSelected ->
let updateItem m = if m.id == id then { m | selected = isSelected } else m
in
{ model | items = List.map updateItem model.items }
ShowMap id showMap ->
let updateItem m = if m.id == id then { m | showmap = showMap } else m
in
{ model | items = List.map updateItem model.items }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment