Skip to main content

disposable_effect

Function disposable_effect 

Source
pub fn disposable_effect<K, F>(key: K, effect: F)
where K: PartialEq + 'static, F: FnOnce() -> DisposableEffectResult + 'static,
Expand description

Runs effect after this call site enters the composition and again whenever key changes, and runs the cleanup it returned before the next run and when the call site leaves. Compose’s DisposableEffect.

ⓘ
disposable_effect(channel.clone(), move || {
    let subscription = subscribe(&channel);
    on_dispose(move || drop(subscription))
});