sycamore::reactive

Function on_cleanup

pub fn on_cleanup(f: impl FnOnce() + 'static)
Expand description

Adds a callback that is called when the scope is destroyed.

ยงExample

let child_scope = create_child_scope(|| {
    on_cleanup(|| {
        println!("Child scope is being dropped");
    });
});
child_scope.dispose(); // Executes the on_cleanup callback.