Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

App-lifecycle support for the backend compiled into THIS binary (docs/lifecycle.md).

Register handlers with on_lifecycle; guard phases a platform may not deliver either at runtime (if day::lifecycle::supported(p) { … }) or at compile time with require_lifecycle!.

Enums§

Lifecycle
An app-lifecycle phase (docs/lifecycle.md). Each backend maps these onto its OS’s native app / activity delegate. Some phases only exist on some platforms — a mobile app truly enters the background and can be low on memory, a desktop app essentially cannot — so Lifecycle::is_universal marks the ones every backend delivers, and Toolkit::supports_lifecycle reports per-backend truth.

Functions§

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 f to run whenever the app reaches phase. Handlers run in registration order, in a reactive batch (signal writes coalesce into one UI update). Register early — before launch, or at the top of the root builder — so WillLaunch/DidLaunch handlers are in place when they fire.
supported
Does the backend compiled into this binary deliver phase? A const fn, so it drives both a runtime guard and the compile-time crate::require_lifecycle! assertion. Agrees with the runtime day_core::lifecycle_supported once the app is running.
Day API ↩ Guides· daybrite.dev