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 and forDidExit. - lifecycle_
supported - Does the running backend deliver
phase? Use this to guard registration at runtime:if day::lifecycle_supported(Lifecycle::DidEnterBackground) { on_lifecycle(...) }. - note_
launch - Record the app’s name and version for the exit line, and start its clock. Called by
launch_withbeforeWillLaunch. - 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. - reset_
handlers - Forget every registered handler: a re-mount (docs/settings.md “Appearance on Android”).
The app’s
root()is about to run again and re-register, and handlers left from the previous mount would fire a second time for every phase. - resident_
memory - The process’s resident memory in bytes, from the platform’s own accounting: the task’s
physical footprint on Apple platforms, the resident set from
/procon Linux and its relatives, the working set on Windows, the linear memory on wasm.Nonewhere none is readable, which the exit line reports as unknown. - 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.