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