pub struct Signal<T>where
T: 'static,{ /* private fields */ }Expand description
Zero-overhead Copy handle to a fine-grained reactive signal stored in the arena.
Implementations§
Source§impl<T> Signal<T>where
T: 'static,
Core reactive operations for Signal<T>.
impl<T> Signal<T>where
T: 'static,
Core reactive operations for Signal<T>.
Sourcepub fn new_detached(initial_value: T) -> Self
pub fn new_detached(initial_value: T) -> Self
Sourcepub fn has_subscribers(&self) -> bool
pub fn has_subscribers(&self) -> bool
Sourcepub fn subscriber_count(&self) -> usize
pub fn subscriber_count(&self) -> usize
Sourcepub fn track(&self)
pub fn track(&self)
Records a dependency on this signal in the active observer without cloning its value.
§Arguments
&Self- Signal handle to track.
Sourcepub fn try_get_untracked(&self) -> Option<T>where
T: Clone,
pub fn try_get_untracked(&self) -> Option<T>where
T: Clone,
Sourcepub fn get_untracked(&self) -> T
pub fn get_untracked(&self) -> T
Sourcepub fn try_with_ref<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>
pub fn try_with_ref<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>
Applies f directly to a shared borrowed &T inside the arena without cloning, returning None if disposed or mutably borrowed.
§Arguments
&Self- Signal handle to borrow.impl FnOnce(&T) -> R- Read-only closure receiving&T(nestedwith_refcalls are supported).
§Returns
Option<R>- Closure return value when the signal is alive and readable.
Sourcepub fn try_with_ref_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>
pub fn try_with_ref_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> Option<R>
Applies f directly to a shared borrowed &T without tracking dependencies or cloning, returning None if disposed or mutably borrowed.
§Arguments
&Self- Signal handle to borrow untracked.impl FnOnce(&T) -> R- Read-only closure receiving&T.
§Returns
Option<R>- Closure return value when the signal is alive and readable.
Sourcepub fn with_ref<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with_ref<R>(&self, f: impl FnOnce(&T) -> R) -> R
Applies f directly to a shared borrowed &T inside the arena without cloning and tracks the active observer dependency.
§Arguments
&Self- Signal handle to borrow.impl FnOnce(&T) -> R- Read-only closure receiving&T(nested read-onlywith_refcalls are supported; do not mutate signals insidef).
§Returns
R- Value returned byf.
Sourcepub fn set_if_changed(&self, value: T) -> boolwhere
T: PartialEq,
pub fn set_if_changed(&self, value: T) -> boolwhere
T: PartialEq,
Trait Implementations§
Source§impl<T> Clone for Signal<T>where
T: 'static,
Manual Clone implementation so Signal<T> is always Copy regardless of T.
impl<T> Clone for Signal<T>where
T: 'static,
Manual Clone implementation so Signal<T> is always Copy regardless of T.
impl<T> Copy for Signal<T>where
T: 'static,
Marker Copy implementation for Signal<T>.
Source§impl<T> Default for Signal<T>where
T: 'static,
Zero-allocation dangling Default handle for Signal<T>, used when initializing component prop descriptors.
impl<T> Default for Signal<T>where
T: 'static,
Zero-allocation dangling Default handle for Signal<T>, used when initializing component prop descriptors.
impl<T> Eq for Signal<T>where
T: 'static,
Reflexive equality for Signal<T>.
Source§impl<T> Hash for Signal<T>where
T: 'static,
Hash implementation based on underlying SignalId.
impl<T> Hash for Signal<T>where
T: 'static,
Hash implementation based on underlying SignalId.