pub fn create_scope<'disposer>(
    f: impl for<'a> FnOnce(Scope<'a>)
) -> ScopeDisposer<'disposer>
Expand description

Creates a reactive scope.

Returns a disposer function which will release the memory owned by the Scope. Failure to call the disposer function will result in a memory leak.

The callback closure is called in an untracked scope.

Scope lifetime

The lifetime of the child scope is arbitrary. As such, it is impossible for anything allocated in the scope to escape out of the scope because it is possible for the scope lifetime to be longer than outside.

let mut outer = None;
create_scope(|cx| {
    outer = Some(cx);
});

Examples

let disposer = create_scope(|cx| {
    // Use cx here.
});
unsafe { disposer.dispose(); }