pub fn launched_effect<K, F, Fut>(key: K, block: F)Expand description
Runs block’s future when this call site enters the composition, and again, after
cancelling the last one, whenever key changes. Cancelled when the call site leaves.
Compose’s LaunchedEffect.
The future is polled on the UI thread. It may wait as long as it likes: waiting costs
nothing, and whatever wakes it asks for a frame. Work that takes time to compute goes
through with_worker so that the UI thread only ever resumes with the answer.
ⓘ
let seconds = remember(|| mutable_state_of(0));
launched_effect((), move || async move {
loop {
delay(Duration::from_secs(1)).await;
seconds.update(|seconds| *seconds += 1);
}
});