Skip to main content

Binding

Trait Binding 

Source
pub trait Binding<T>: Clone + 'static
where T: 'static,
{ // Required methods fn read(&self) -> T; fn peek(&self) -> T; fn write(&self, v: T); // Provided methods fn write_preview(&self, v: T) { ... } fn write_commit(&self, v: T) { ... } fn write_teardown(&self, v: T) { ... } }
Expand description

A readable-writable value a control can bind to two-way: a Signal, or any projection that knows how to read and write its own slot (day-model’s Field is the other implementor).

The trait lives here rather than in day-pieces so a store crate can implement it without depending on the piece vocabulary; day-pieces re-exports it, so piece code sees no move.

Required Methods§

Source

fn read(&self) -> T

Tracked read: the current value, subscribing the running computation to changes.

Source

fn peek(&self) -> T

Untracked read: the current value, subscribing nothing (the reactive world’s “peek”).

Source

fn write(&self, v: T)

Write the value, waking whatever tracks it.

Provided Methods§

Source

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)

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)

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Binding<T> for AnyBinding<T>
where T: 'static,

Source§

impl<T> Binding<T> for Signal<T>
where T: Clone + 'static,

Day API ↩ Guides· daybrite.dev