Page lifecycle hooks for enter/exit transitions and loading states.
These are composable modifiers applied via pipeline to any page:
blogPage =
Page.element { ... }
|> Transition.onEnter (\shared -> loadPosts shared.apiUrl)
|> Transition.onLeave (\shared model -> saveDraft model.draft)
|> Transition.withLoading loadingView
|> Transition.keepAliveLifecycle metadata for a page. Stored alongside the page, not inside it, because the App module needs access to manage page transitions.
Add an onEnter hook. The command is fired when the page becomes active.
myLifecycle =
Transition.lifecycle
|> Transition.onEnter (\shared -> loadData shared.apiUrl)Add an onLeave hook. The command is fired when navigating away from the page.
myLifecycle =
Transition.lifecycle
|> Transition.onLeave (\shared model -> saveDraft model.draft)Set a loading view shown while onEnter commands are in-flight.
myLifecycle =
Transition.lifecycle
|> Transition.withLoading (\shared -> Html.text "Loading...")Mark the page as keep-alive. When navigating away, the model is preserved instead of being destroyed. When returning to this page, the preserved model is reused instead of running init again.
myLifecycle =
Transition.lifecycle
|> Transition.keepAliveGet the onEnter command producer, if any.
Get the onLeave command producer, if any.
Check if the page is marked as keep-alive.
The loading state of a page.