Created
June 28, 2019 08:37
-
-
Save owanturist/9e2a5589ab00fed411527200909c0e08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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