pub struct Signal<T: 'static> { /* private fields */ }Expand description
A value that the reactive closures reading it follow. Copy: a move
closure takes it without a clone.
Implementations§
Source§impl<T: 'static> Signal<T>
impl<T: 'static> Signal<T>
Sourcepub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
Calls f with the value, and records the read when a memo or an
effect is running.
Sourcepub fn with_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> R
Calls f with the value without recording the read.
Sourcepub fn get_untracked(&self) -> Twhere
T: Clone,
pub fn get_untracked(&self) -> Twhere
T: Clone,
A copy of the value; the read is not recorded.
Sourcepub fn set_if_changed(&self, value: T)where
T: PartialEq,
pub fn set_if_changed(&self, value: T)where
T: PartialEq,
Replaces the value when it differs from the one held; a value that is equal changes nothing and runs nothing.
Sourcepub fn update(&self, f: impl FnOnce(&mut T))
pub fn update(&self, f: impl FnOnce(&mut T))
Changes the value in place, and runs what reads it.
Sourcepub fn take(&self) -> Twhere
T: Default,
pub fn take(&self) -> Twhere
T: Default,
Takes the value, leaving the default, and runs what reads it.
Trait Implementations§
impl<T: 'static> Copy for Signal<T>
Source§impl<T: PropertyValue, V: IntoValue<T> + Clone + 'static> IntoProp<T, FromSignal<V>> for Signal<V>
impl<T: PropertyValue, V: IntoValue<T> + Clone + 'static> IntoProp<T, FromSignal<V>> for Signal<V>
Auto Trait Implementations§
impl<T> Freeze for Signal<T>
impl<T> RefUnwindSafe for Signal<T>
impl<T> Send for Signal<T>
impl<T> Sync for Signal<T>
impl<T> Unpin for Signal<T>
impl<T> UnsafeUnpin for Signal<T>
impl<T> UnwindSafe for Signal<T>
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
Source§impl<T> AnyValueEq for Twhere
T: PartialEq + 'static,
impl<T> AnyValueEq for Twhere
T: PartialEq + 'static,
Source§fn item_equals(&self, other: &(dyn AnyValueEq + 'static)) -> bool
fn item_equals(&self, other: &(dyn AnyValueEq + 'static)) -> bool
Whether
other holds an equal value.Source§fn item_as_any(&self) -> &(dyn Any + 'static)
fn item_as_any(&self) -> &(dyn Any + 'static)
The value as
Any.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromValue<Option<T>> for Twhere
T: Clone,
impl<T> FromValue<Option<T>> for Twhere
T: Clone,
Source§fn from_value(value: &Option<T>) -> Option<T>
fn from_value(value: &Option<T>) -> Option<T>
The value of the signal, or
None when the value of the property has
none (the signal keeps its value).Source§impl<T> FromValue<T> for Twhere
T: Clone,
impl<T> FromValue<T> for Twhere
T: Clone,
Source§fn from_value(value: &T) -> Option<T>
fn from_value(value: &T) -> Option<T>
The value of the signal, or
None when the value of the property has
none (the signal keeps its value).Source§impl<T> IntoValue<Option<T>> for Twhere
T: PropertyValue,
impl<T> IntoValue<Option<T>> for Twhere
T: PropertyValue,
Source§fn into_value(self) -> Option<T>
fn into_value(self) -> Option<T>
The value of the property.