pub fn on_cleanup(f: impl FnOnce() + 'static) {
    SCOPES.with(|scope| {
        if scope.borrow().last().is_some() {
            scope
                .borrow_mut()
                .last_mut()
                .unwrap_throw()
                .add_cleanup(Box::new(f));
        } else {
            #[cfg(all(target_arch = "wasm32", debug_assertions))]
            web_sys::console::warn_1(
                &"Cleanup callbacks created outside of a reactive root will never run.".into(),
            );
            #[cfg(all(not(target_arch = "wasm32"), debug_assertions))]
            eprintln!(
                "WARNING: Cleanup callbacks created outside of a reactive root will never run."
            );
        }
    });
}
/// Adds a callback function to the current reactive scope's cleanup.
///
/// # Example
/// ```
/// use sycamore_reactive::*;
///
/// let cleanup_called = Signal::new(false);
///
/// let scope = create_root(cloned!((cleanup_called) => move || {
///     on_cleanup(move || {
///         cleanup_called.set(true);
///     })
/// }));
///
/// assert_eq!(*cleanup_called.get(), false);
///
/// drop(scope);
/// assert_eq!(*cleanup_called.get(), true);
/// ```
Adds a callback function to the current reactive scope's cleanup.
Adds a callback function to the current reactive scope ' s cleanup .
pub fn on_cleanup(f: impl FnOnce() + 'static) {
    SCOPES.with(|scope| {
        if scope.borrow().last().is_some() {
            scope
                .borrow_mut()
                .last_mut()
                .unwrap_throw()
                .add_cleanup(Box::new(f));
        } else {
            #[cfg(all(target_arch = "wasm32", debug_assertions))]
            web_sys::console::warn_1(
                &"Cleanup callbacks created outside of a reactive root will never run.".into(),
            );
            #[cfg(all(not(target_arch = "wasm32"), debug_assertions))]
            eprintln!(
                "WARNING: Cleanup callbacks created outside of a reactive root will never run."
            );
        }
    });
}
pub fn on_cleanup ( f : impl FnOnce ( ) + ' static ) { SCOPES . with ( | scope | { if scope . borrow ( ) . last ( ) . is_some ( ) { scope . borrow_mut ( ) . last_mut ( ) . unwrap_throw ( ) . add_cleanup ( Box :: new ( f ) ) ; } else { # [ cfg ( all ( target_arch " " debug_assertions ) ) ] web_sys :: console :: warn_1 ( & " " . into ( ) , ) ; # [ cfg ( all ( not ( target_arch " " ) debug_assertions ) ) ] eprintln ! ( " " ) ; } } ) ; }
Adds a callback function to the current reactive scope's cleanup.
Adds a callback function to the current reactive scope ' s cleanup .
f
impl FnOnce() + 'static
example
```
use sycamore_reactive::*.

let cleanup_called = Signal::new(false).

let scope = create_root(cloned!((cleanup_called) => move || {
on_cleanup(move || {
cleanup_called.set(true);
})
})).

assert_eq!(*cleanup_called.get(), false).

drop(scope);
assert_eq!(*cleanup_called.get(), true);
```
` ` ` use sycamore_reactive :: * . let cleanup_called = Signal :: new ( false ) . let scope = create_root ( cloned! (( cleanup_called ) = > move || { on_cleanup ( move || { cleanup_called . set ( true ) ; } ) } )) . assert_eq! ( * cleanup_called . get () false ) . drop ( scope ) ; assert_eq! ( * cleanup_called . get () true ) ; ` ` `