Function sycamore::reactive::create_effect_scoped
source · [−]pub fn create_effect_scoped<'a, F>(cx: BoundedScope<'a, 'a>, f: F)where
F: 'a + for<'child_lifetime> FnMut(BoundedScope<'child_lifetime, 'a>),
Expand description
Creates an effect on signals used inside the effect closure.
Instead of create_effect
, this function also provides a new
reactive scope instead the effect closure. This scope is created for each new run of the
effect.
Items created within the scope cannot escape outside the effect because that can result in an use-after-free.
Example
create_effect_scoped(cx, |cx| {
// Use the scoped cx inside here.
let _nested_signal = create_signal(cx, 0);
// _nested_signal cannot escape out of the effect closure.
});