on master help sign in
Added document and element
commit9bf0a783f7f38efc7fe904c66989e97cbf02f791 authoriko <mail@iko.soy> dateSat 17 Jun 2023, 15:01 (3 years ago) parentfe9c4e6
1 file changed+52−2
src/Ur/Run.elm+52−2
src/Ur/Run.elm+52−2
@@ -1,10 +1,17 @@
1−module Ur.Run exposing (Model, Msg, Program, application)
1+module Ur.Run exposing
2+ ( Model
3+ , Msg
4+ , Program
5+ , application
6+ , document
7+ , element
8+ )
29
310import Browser exposing (Document, UrlRequest)
411import Browser.Navigation as Nav
512import Dict exposing (Dict)
613import Either exposing (Either(..))
7−import Html
14+import Html exposing (Html)
815import Json.Decode as JD
916import Task
1017import Time
@@ -59,6 +66,49 @@ type alias Program model msg =
5966 Platform.Program Flags (Model model msg) (Msg msg)
6067
6168
69+element :
70+ { init : ( model, Ur.Cmd.Cmd msg )
71+ , view : model -> Html msg
72+ , update : msg -> model -> ( model, Ur.Cmd.Cmd msg )
73+ , subscriptions : model -> Sub msg
74+ , urbitSubscriptions : model -> Ur.Sub.Sub msg
75+ , createEventSource : String -> Cmd (Msg msg)
76+ , onEventSourceMsg : (JD.Value -> Msg msg) -> Sub (Msg msg)
77+ , urbitUrl : model -> String
78+ }
79+ -> Program model msg
80+element inp =
81+ Browser.element
82+ { init = init inp inp.init
83+ , view = \model -> inp.view model.app |> Html.map AppMsg
84+ , update = update inp
85+ , subscriptions = subscriptions inp
86+ }
87+
88+
89+document :
90+ { init : ( model, Ur.Cmd.Cmd msg )
91+ , view : model -> Document msg
92+ , update : msg -> model -> ( model, Ur.Cmd.Cmd msg )
93+ , subscriptions : model -> Sub msg
94+ , urbitSubscriptions : model -> Ur.Sub.Sub msg
95+ , createEventSource : String -> Cmd (Msg msg)
96+ , onEventSourceMsg : (JD.Value -> Msg msg) -> Sub (Msg msg)
97+ , urbitUrl : model -> String
98+ }
99+ -> Program model msg
100+document inp =
101+ Browser.document
102+ { init = init inp inp.init
103+ , view =
104+ \model ->
105+ inp.view model.app
106+ |> (\{ body, title } -> { title = title, body = body |> List.map (Html.map AppMsg) })
107+ , update = update inp
108+ , subscriptions = subscriptions inp
109+ }
110+
111+
62112application :
63113 { init : Url -> Nav.Key -> ( model, Ur.Cmd.Cmd msg )
64114 , view : model -> Document msg