pub struct Signal<T> { /* private fields */ }Expand description
Mutable state: a Copy handle (closures capture it as is). It belongs
to the owner current when it was made (see the module docs) and is freed
with it; afterwards reading it panics and setting it does nothing.
Implementations§
Source§impl<T: 'static> Signal<T>
impl<T: 'static> Signal<T>
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Whether the signal still exists (its owner hasn’t been dropped).
Sourcepub fn try_get(&self) -> Option<T>where
T: Clone,
pub fn try_get(&self) -> Option<T>where
T: Clone,
A copy of the value, subscribing the running effect; None once the
signal was freed.
Sourcepub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
Reads the value through f, subscribing the running effect.
Sourcepub fn get_untracked(&self) -> Twhere
T: Clone,
pub fn get_untracked(&self) -> Twhere
T: Clone,
A copy of the value, without subscribing.
Sourcepub fn with_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with_untracked<R>(&self, f: impl FnOnce(&T) -> R) -> R
Reads the value through f without subscribing: like
with, for a large value (a Vec, a tree) that an
effect reads but shouldn’t re-run for.
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 and notifies readers only if it changed.
Trait Implementations§
impl<T> Copy for Signal<T>
impl<T> Eq for Signal<T>
Auto Trait Implementations§
impl<T> !Send for Signal<T>
impl<T> !Sync for Signal<T>
impl<T> Forget for Signal<T>
impl<T> Freeze for Signal<T>
impl<T> Move for Signal<T>
impl<T> RefUnwindSafe for Signal<T>
impl<T> Unpin for Signal<T>
impl<T> UnsafeUnpin for Signal<T>
impl<T> UnwindSafe for Signal<T>
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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