pub struct Scope(/* private fields */);Expand description
You can manually control Signal’s lifetime by using Scope.
Every Signal has a Scope created explicitly or implicitly, and when you Dispose the Scope, it will clean up all the Signals that belong to the Scope and all the child Scopes
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn current() -> Scope
pub fn current() -> Scope
The current Scope in the Runtime. Any Signal/Effect/Memo created with implicitly Scope will be under this Scope
Sourcepub fn create_child(&self) -> Scope
pub fn create_child(&self) -> Scope
Create a child Scope of this Scope
Sourcepub fn create_signal<T>(self, value: T) -> (ReadSignal<T>, WriteSignal<T>)where
T: Any + 'static,
pub fn create_signal<T>(self, value: T) -> (ReadSignal<T>, WriteSignal<T>)where
T: Any + 'static,
Create a new Signal under this Scope
Sourcepub fn create_rw_signal<T>(self, value: T) -> RwSignal<T>where
T: Any + 'static,
pub fn create_rw_signal<T>(self, value: T) -> RwSignal<T>where
T: Any + 'static,
Create a RwSignal under this Scope (local/unsync by default)
Sourcepub fn create_sync_signal<T>(
self,
value: T,
) -> (ReadSignal<T, SyncStorage>, WriteSignal<T, SyncStorage>)
pub fn create_sync_signal<T>( self, value: T, ) -> (ReadSignal<T, SyncStorage>, WriteSignal<T, SyncStorage>)
Create a sync Signal under this Scope
Sourcepub fn create_sync_rw_signal<T>(self, value: T) -> RwSignal<T, SyncStorage>
pub fn create_sync_rw_signal<T>(self, value: T) -> RwSignal<T, SyncStorage>
Create a sync RwSignal under this Scope
Sourcepub fn create_local_signal<T>(
self,
value: T,
) -> (ReadSignal<T, UnsyncStorage>, WriteSignal<T, UnsyncStorage>)where
T: Any + 'static,
pub fn create_local_signal<T>(
self,
value: T,
) -> (ReadSignal<T, UnsyncStorage>, WriteSignal<T, UnsyncStorage>)where
T: Any + 'static,
Create a local (unsync) Signal under this Scope
Sourcepub fn create_local_rw_signal<T>(self, value: T) -> RwSignal<T, UnsyncStorage>where
T: Any + 'static,
pub fn create_local_rw_signal<T>(self, value: T) -> RwSignal<T, UnsyncStorage>where
T: Any + 'static,
Create a local (unsync) RwSignal under this Scope
Sourcepub fn create_memo<T>(self, f: impl Fn(Option<&T>) -> T + 'static) -> Memo<T>where
T: PartialEq + 'static,
pub fn create_memo<T>(self, f: impl Fn(Option<&T>) -> T + 'static) -> Memo<T>where
T: PartialEq + 'static,
Create a Memo under this Scope
Sourcepub fn create_trigger(self) -> Trigger
pub fn create_trigger(self) -> Trigger
Create a Trigger under this Scope
Sourcepub fn create_effect<T>(self, f: impl Fn(Option<T>) -> T + 'static)where
T: Any + 'static,
pub fn create_effect<T>(self, f: impl Fn(Option<T>) -> T + 'static)where
T: Any + 'static,
Create effect under this Scope
Sourcepub fn create_updater<R>(
self,
compute: impl Fn() -> R + 'static,
on_change: impl Fn(R) + 'static,
) -> Rwhere
R: 'static,
pub fn create_updater<R>(
self,
compute: impl Fn() -> R + 'static,
on_change: impl Fn(R) + 'static,
) -> Rwhere
R: 'static,
Create updater under this Scope
Sourcepub fn enter<T>(&self, f: impl FnOnce() -> T) -> Twhere
T: 'static,
pub fn enter<T>(&self, f: impl FnOnce() -> T) -> Twhere
T: 'static,
Runs the given closure within this scope.
Sourcepub fn enter_child<T, U>(
&self,
f: impl Fn(T) -> U + 'static,
) -> impl Fn(T) -> (U, Scope)where
T: 'static,
pub fn enter_child<T, U>(
&self,
f: impl Fn(T) -> U + 'static,
) -> impl Fn(T) -> (U, Scope)where
T: 'static,
Wraps a closure so it runs under a new child scope of this scope.