Top-level application wiring.
Takes routes, pages, shared state configuration, and produces a
Browser.application Program.
main : Program Flags Model Msg
main =
App.create
{ init = init
, router = router
, toRoute = toRoute
, toPage = toPage
, notFound = notFoundView
, shared =
{ init = sharedInit
, update = sharedUpdate
, subscriptions = sharedSubscriptions
}
, layout = \_ _ -> Layout.none
}The application model.
The application message type.
A page view bundles the page's init/update/view/subscriptions in a
uniform type. Created via App.page.
Create a Browser.application from the config.
This is the main entry point. It wires together routing, page lifecycle, shared state, and the Elm runtime.
main =
App.create { ... }Create a PageView from a page's functions and model/msg wrappers.
toPage : Route -> Shared -> PageView Shared PageModel PageMsg
toPage route shared =
case route of
Home ->
App.page
{ init = \_ -> ( (), Cmd.none )
, update = \_ m -> ( m, Cmd.none )
, view = \_ _ -> Html.text "Home"
, subscriptions = \_ _ -> Sub.none
}
Configuration for creating an App.
router: the Route.Router for URL parsingtoRoute: function that determines the current route from a URL, with a fallbacktoPage: given a route and shared state, produces the page viewnotFound: view shown for unmatched URLsshared: shared state init/update/subscriptions