Skip to content

Instantly share code, notes, and snippets.

@owanturist
Created June 28, 2019 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save owanturist/9e2a5589ab00fed411527200909c0e08 to your computer and use it in GitHub Desktop.
Save owanturist/9e2a5589ab00fed411527200909c0e08 to your computer and use it in GitHub Desktop.
type FrontendMsg
= FNoop
| Increment
| Decrement
| OnBackendMsg ToFrontend
update : FrontendMsg -> Model -> ( Model, Cmd FrontendMsg )
update msg model =
case msg of
FNoop ->
( model, Cmd.none )
Increment ->
( { model | counter = model.counter + 1 }
, sendToBackend CounterIncremented
)
Decrement ->
( { model | counter = model.counter - 1 }
, sendToBackend CounterDecremented
)
OnBackendMsg (CounterNewValue newValue) ->
( { model | counter = newValue }
, Cmd.none
)
app =
Lamdera.Frontend.application
{ init = \_ _ -> init
, update = update
, onBackendMsg = OnBackendMsg
, view =
\model ->
{ title = "Lamdera board app"
, body = [ view model ]
}
, subscriptions = \_ -> Sub.none
, onUrlChange = \_ -> FNoop
, onUrlRequest = \_ -> FNoop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment