Expand description
App-lifecycle callbacks (docs/lifecycle.md). An app registers closures for day_spec::Lifecycle
phases with on_lifecycle; each backend, at the matching moment in its native app/activity
delegate, emits Event::Lifecycle(phase) (or day-core dispatches the launch phases uniformly),
and the event pump routes it here to run the closures inside a reactive batch — the same rails as
Event::MenuAction, so a lifecycle handler that writes signals updates the UI like any callback.
Not every platform has every phase (a desktop app doesn’t really enter the background), so a
handler registered for a phase the running backend doesn’t deliver gets a one-time warning, and
apps can guard with lifecycle_supported (runtime) or day::require_lifecycle! (compile time).
Functions§
- dispatch_
lifecycle - Run every handler registered for
phase, in a reactive batch. Called by the event pump onEvent::Lifecycle, and directly bylaunch_withfor the launch phases. - lifecycle_
supported - Does the running backend deliver
phase? Use this to guard registration at runtime:if day::lifecycle_supported(Lifecycle::DidEnterBackground) { on_lifecycle(...) }. - on_
lifecycle - Register
fto run whenever the app reachesphase. Handlers run in registration order, in a reactive batch (signal writes coalesce into one UI update). Register early — beforelaunch, or at the top of the root builder — soWillLaunch/DidLaunchhandlers are in place when they fire. - warn_
unsupported_ registrations - Warn once for every ALREADY-registered phase the (now-known) backend doesn’t deliver. Called by
launch_withright after the backend/tree is installed, covering handlers registered before launch.