pub struct OneWayBinding<T: Clone + 'static> { /* private fields */ }Expand description
A one-way binding that pushes signal changes to a property sink.
When the source signal changes, the binding reads the new value
and calls PropertySink::set_value on the sink.
§Examples
ⓘ
let count = Signal::new(0);
let display = Rc::new(RefCell::new(String::new()));
let binding = OneWayBinding::new(&count, {
let display = display.clone();
move |v: &i32| *display.borrow_mut() = format!("{v}")
});
count.set(42);
assert_eq!(*display.borrow(), "42");Implementations§
Source§impl<T: Clone + 'static> OneWayBinding<T>
impl<T: Clone + 'static> OneWayBinding<T>
Sourcepub fn new(source: &Signal<T>, sink: impl PropertySink<T> + 'static) -> Self
pub fn new(source: &Signal<T>, sink: impl PropertySink<T> + 'static) -> Self
Create a new one-way binding from source to sink.
The sink is called immediately with the current value, and again whenever the source signal changes.
Trait Implementations§
Source§impl<T: Clone + 'static> Binding for OneWayBinding<T>
impl<T: Clone + 'static> Binding for OneWayBinding<T>
Auto Trait Implementations§
impl<T> Freeze for OneWayBinding<T>
impl<T> !RefUnwindSafe for OneWayBinding<T>
impl<T> !Send for OneWayBinding<T>
impl<T> !Sync for OneWayBinding<T>
impl<T> Unpin for OneWayBinding<T>
impl<T> !UnwindSafe for OneWayBinding<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