Skip to main content

on_lifecycle

Function on_lifecycle 

Source
pub fn on_lifecycle(phase: Lifecycle, f: impl Fn() + 'static)
Expand description

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.

If the running backend doesn’t deliver phase (e.g. DidEnterBackground on desktop), the handler is kept but will never run, and a one-time warning is logged. Prefer guarding the registration with lifecycle_supported or the day::require_lifecycle! compile-time check.

Day API ↩ Guides· daybrite.dev