Skip to main content

spawn_effect

Function spawn_effect 

Source
pub fn spawn_effect<T: Send + 'static>(
    name: &'static str,
    emit: impl FnOnce(Outcome<T>) + Send + 'static,
    work: impl FnOnce(CancelToken) -> Outcome<T> + Send + 'static,
) -> CancelHandle
Expand description

Cancellation requests stop resources promptly but do not replace a mutation receipt. The work closure always runs and must check its token before effects, allowing it to return exact per-item cancellations even before native launch. Cleanup failure preserves a successful observed value in Failed.partial.