pub struct Signal<T: 'static> { /* private fields */ }Expand description
A Copy, !Send reactive value handle (§4.2).
Implementations§
Source§impl<T: 'static> Signal<T>
impl<T: 'static> Signal<T>
pub fn new(value: T) -> Self
Sourcepub fn global(value: T) -> Self
pub fn global(value: T) -> Self
A process-global signal: allocated in the root scope regardless of where the call
runs, so it never dies with a transient caller. Every lazily-initialized global
registry must use this, not Signal::new, because a lazy global first touched inside a
presented cover / pushed page / when arm otherwise inherits that scope and is
disposed with it, and every later read panics (the day-l10n locale signal was the
observed case).
pub fn new_in(scope: Scope, value: T) -> Self
pub fn try_with<R>(self, f: impl FnOnce(&T) -> R) -> Option<R>
pub fn with_untracked<R>(self, f: impl FnOnce(&T) -> R) -> R
pub fn get(self) -> Twhere
T: Clone,
pub fn try_get(self) -> Option<T>where
T: Clone,
pub fn get_untracked(self) -> Twhere
T: Clone,
pub fn set(self, value: T)
pub fn set_if_changed(self, value: T)where
T: PartialEq,
pub fn update(self, f: impl FnOnce(&mut T))
Trait Implementations§
Source§impl<T: Clone + 'static> Binding<T> for Signal<T>
impl<T: Clone + 'static> Binding<T> for Signal<T>
Source§fn read(&self) -> T
fn read(&self) -> T
Tracked read: the current value, subscribing the running computation to changes.
Source§fn peek(&self) -> T
fn peek(&self) -> T
Untracked read: the current value, subscribing nothing (the reactive world’s “peek”).
Source§fn write_teardown(&self, _v: T)
fn write_teardown(&self, _v: T)
Seal the last preview when its control is disposed. Persistent bindings default to
committing; scope-owned signals have already received the preview and may be gone.
Source§fn write_preview(&self, v: T)
fn write_preview(&self, v: T)
A live write mid-gesture (
Event::ValueChanged): readers must follow, but nothing
durable should key off it. Defaults to Binding::write: a plain signal has no
notion of “durable”, and a degraded backend that never commits stays correct.Source§fn write_commit(&self, v: T)
fn write_commit(&self, v: T)
The settled value that ends a gesture (
Event::ValueCommitted). Defaults to
Binding::write; a day-model field seals its preview session here: one change
record, one undo unit, one UPDATE for the whole drag.impl<T: 'static> Copy for Signal<T>
Auto Trait Implementations§
impl<T> !Send for Signal<T>
impl<T> !Sync for Signal<T>
impl<T> Freeze for Signal<T>
impl<T> RefUnwindSafe for Signal<T>where
T: RefUnwindSafe,
impl<T> Unpin for Signal<T>
impl<T> UnsafeUnpin for Signal<T>
impl<T> UnwindSafe for Signal<T>where
T: RefUnwindSafe,
Blanket Implementations§
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