Trait viewbuilder::Object
source · pub trait Object: Sized {
type Handle: From<HandleState<Self>> + Clone;
// Provided method
fn spawn(self) -> Handle<Self>
where Self: 'static { ... }
}Expand description
A reactive object.
Required Associated Types§
sourcetype Handle: From<HandleState<Self>> + Clone
type Handle: From<HandleState<Self>> + Clone
Handle for this object.
Provided Methods§
sourcefn spawn(self) -> Handle<Self>where
Self: 'static,
fn spawn(self) -> Handle<Self>where
Self: 'static,
Spawn this object and return a handle to it.
Examples found in repository?
More examples
examples/counter.rs (line 25)
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);
}Object Safety§
This trait is not object safe.