Struct viewbuilder::Handle
source · pub struct Handle<O: Object> { /* private fields */ }Implementations§
source§impl<O: Object> Handle<O>
impl<O: Object> Handle<O>
pub fn key(&self) -> DefaultKey
sourcepub fn update(&self, f: impl FnMut(&mut O) + 'static)where
O: 'static,
pub fn update(&self, f: impl FnMut(&mut O) + 'static)where
O: 'static,
Send an update to the object.
sourcepub fn borrow(&self) -> Ref<O>
pub fn borrow(&self) -> Ref<O>
Immutably borrow the object.
Examples found in repository?
examples/counter.rs (line 33)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
async fn main() {
let rt = Runtime::default();
let _guard = rt.enter();
let a = Counter::default().spawn();
let b = Counter::default().spawn();
a.value_changed().bind(&b, Counter::set);
a.set(2);
rt.run().await;
assert_eq!(a.borrow().value, 2);
assert_eq!(b.borrow().value, 2);
}Trait Implementations§
Auto Trait Implementations§
impl<O> RefUnwindSafe for Handle<O>
impl<O> !Send for Handle<O>
impl<O> !Sync for Handle<O>
impl<O> Unpin for Handle<O>
impl<O> UnwindSafe for Handle<O>
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