Ui.App

Ui.App is the starting point of any Elm-UI application, it has multiple responsibilities:

  • Loads the CSS file and provides a subscription to handle loaded state
  • Schedules updates for the Ui.Time component
  • Sets the viewport meta tag to be mobile friendly
  • Sets the title of the window

Loaded State

When the stylesheet is loaded the Ui.App will send an event (via Emitter) that you can subscribe to with the subscribe event.

Example Usage

import Html exposing (text)
import Html.App

import Ui.Native.Browser as Browser
import Ui.App


type Msg
  = App Ui.App.Msg
  | Loaded Bool


type alias Model =
  { app : Ui.App.Model }


init : Model
init =
  { app = Ui.App.init "My App..."
  }


view : Model -> Html.Html Msg
view model =
  Ui.App.view
    App
    model.app
    [ text "Hello World!" ]


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
  case msg of
    Loaded state ->
      ( Browser.alert "App loaded" model, Cmd.none )

    App subMsg ->
      let
        ( app, cmd ) =
          Ui.App.update subMsg model.app
      in
        ( { model | app = app }, Cmd.map App cmd )


main =
  Html.App.program
    { init = ( init, Cmd.none )
    , view = view
    , update = update
    , subscriptions =
        \model ->
          Sub.batch
            [ Ui.App.subscribe Loaded model.app
            , Sub.map App Ui.App.subscriptions
            ]
    }

results matching ""

    No results matching ""