-
Notifications
You must be signed in to change notification settings - Fork 0
/
elmApp.elm
45 lines (33 loc) · 881 Bytes
/
elmApp.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
port module ElmApp exposing (..)
Js : (String -> msg) -> Sub msg
import Browser
import Html exposing (Html, text)
-- Port for receiving messages from JS
port receiveFromJs : (String -> msg) -> Sub msg
type alias Model =
{ message : String }
type Msg
= NflagsMessage String
_
-- The init function for Browserinit : () -> (Model, Cmd Msg)
init () =
({ message = "" }, Cmd.none)
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
NewMessage newMsg ->
({ model | message = newMsg }, Cmd.none)
subscriptions : Model -> Sub Msg
subscriptions model =
receiveFromJs NewMessage
view : Model -> Html Msg
view model =
text model.message
main : Program () Model Msg
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}