pub struct LaunchedEffectScope { /* private fields */ }Expand description
The scope a LaunchedEffect receives. It reports whether the effect is still active and
queues follow-up work on the UI thread.
Implementations§
Source§impl LaunchedEffectScope
impl LaunchedEffectScope
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Returns true until the effect is cancelled, which happens when its keys change or its call
site leaves the composition.
Sourcepub fn runtime(&self) -> RuntimeHandle
pub fn runtime(&self) -> RuntimeHandle
Returns a handle to the runtime that runs the effect.
Sourcepub fn launch(&self, task: impl FnOnce(LaunchedEffectScope) + 'static)
pub fn launch(&self, task: impl FnOnce(LaunchedEffectScope) + 'static)
Runs a follow-up LaunchedEffect task on the UI thread.
The provided closure executes on the runtime thread and may freely
capture Rc/RefCell state. This must only be called from the UI
thread, typically inside another effect callback.
Sourcepub fn post_ui(&self, task: impl FnOnce() + 'static)
pub fn post_ui(&self, task: impl FnOnce() + 'static)
Posts UI-only work that will execute on the runtime thread.
The closure never crosses threads, so it may capture non-Send values.
Callers must invoke this from the UI thread.
Sourcepub fn launch_background<T, Work, Ui, Fut>(&self, work: Work, on_ui: Ui)
pub fn launch_background<T, Work, Ui, Fut>(&self, work: Work, on_ui: Ui)
Runs background work and delivers results to the UI.
On native targets, work runs on a worker thread and its future is
driven to completion there. On WASM, work runs as a task on the
browser event loop. The on_ui continuation always runs on the runtime
thread, so it may capture Rc/RefCell state safely.