pub struct AnyBinding<T>where
T: 'static,{ /* private fields */ }Expand description
A type-erased Binding: what a piece stores when its builder takes impl Binding<T>
(docs/api-style.md “Three input spellings”), so the piece itself needs no type parameter
per bound value.
Copy, like Signal, so it captures into closures the same way: the erased binding lives
in a slot owned by the reactive scope that created it, which is the scope building the
piece. Reads and writes forward to the binding it wraps, preview and commit included.
Implementations§
Source§impl<T> AnyBinding<T>where
T: 'static,
impl<T> AnyBinding<T>where
T: 'static,
Sourcepub fn new(binding: impl Binding<T>) -> AnyBinding<T>
pub fn new(binding: impl Binding<T>) -> AnyBinding<T>
Erase binding. Call it where the piece is built: the slot belongs to the current scope.
Sourcepub fn try_get(self) -> Option<T>
pub fn try_get(self) -> Option<T>
Tracked read, or None once the scope that created the binding is disposed.
Sourcepub fn get_untracked(self) -> T
pub fn get_untracked(self) -> T
Untracked read.
Sourcepub fn set_if_changed(self, v: T)where
T: PartialEq,
pub fn set_if_changed(self, v: T)where
T: PartialEq,
Write only when the value differs from the current one.
Trait Implementations§
Source§impl<T> Binding<T> for AnyBinding<T>where
T: 'static,
impl<T> Binding<T> for AnyBinding<T>where
T: 'static,
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_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.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 end_preview(&self)
fn end_preview(&self)
Close an open preview session without recording it: the app wrote a value of its own over
what the gesture previewed (a text field’s text replaced while being typed in), and that
write recorded its own change. The next preview starts a fresh session whose prior is
the app’s value. Defaults to nothing: a plain signal keeps no session.
Source§impl<T> Clone for AnyBinding<T>where
T: 'static,
impl<T> Clone for AnyBinding<T>where
T: 'static,
Source§fn clone(&self) -> AnyBinding<T>
fn clone(&self) -> AnyBinding<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T> Copy for AnyBinding<T>where
T: 'static,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for AnyBinding<T>
impl<T> !Send for AnyBinding<T>
impl<T> !Sync for AnyBinding<T>
impl<T> !UnwindSafe for AnyBinding<T>
impl<T> Forget for AnyBinding<T>
impl<T> Freeze for AnyBinding<T>
impl<T> Move for AnyBinding<T>
impl<T> Unpin for AnyBinding<T>
impl<T> UnsafeUnpin for AnyBinding<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<R, S> IntoCoverOpen<R, RouteOpen> for S
impl<R, S> IntoCoverOpen<R, RouteOpen> for S
Source§impl<B> IntoCoverOpen<Shown, BoolOpen> for B
impl<B> IntoCoverOpen<Shown, BoolOpen> for B
Source§const ROUTED: bool = false
const ROUTED: bool = false
Whether the cover registers a string-route adapter (
navigate("<key>")). A bool cover
does not: every bool cover would answer the same key.Source§type Open = ShownBinding<B>
type Open = ShownBinding<B>
The binding the cover reads and writes.
Source§fn into_open(self) -> ShownBinding<B>
fn into_open(self) -> ShownBinding<B>
The binding.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more