@@ -1,36 +1,48 @@
1module Main exposing (..)
1module Main exposing (..)
3import Browser
3import Browser
4import Html exposing (..)
5import Html exposing (..)
7−type alias Msg =
8+type Msg
8− ()
9+ = RecieveMessage String
11type alias Model =
12type alias Model =
12− ()
13+ { messages : List String
15main : Program () Model Msg
17main : Program () Model Msg
17− Browser.sandbox
19+ Browser.element
18− { init = init
20+ { init = \_ -> ( init, Cmd.none )
19 , view = view
21 , view = view
20 , update = update
22 , update = update
23+ , subscriptions = \_ -> FFI.getString RecieveMessage
24init : Model
27init : Model
26− ()
29+ { messages = []
29view : Model -> Html Msg
33view : Model -> Html Msg
30−view _ =
34+view model =
31− h1 [] [ text "HELLO" ]
36+ [ h1 [] [ text "HELLO" ]
32−
37+ , ul [] (model.messages |> List.map (text >> List.singleton >> li []))
34−update : Msg -> Model -> Model
41+update : Msg -> Model -> ( Model, Cmd Msg )
35−update _ model =
42+update msg model =
45+ ( { messages = x :: model.messages