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§

source

type Handle: From<HandleState<Self>> + Clone

Handle for this object.

Provided Methods§

source

fn spawn(self) -> Handle<Self>
where Self: 'static,

Spawn this object and return a handle to it.

Examples found in repository?
examples/app.rs (line 19)
15
16
17
18
19
20
21
22
23
24
25
fn main() {
    let mut app = UserInterface::new();
    let _guard = app.enter();

    let window = Window {}.spawn();
    let example = Example.spawn();
    window.cursor_pos().bind(&example, Example::set_cursor_pos);
    app.insert_window(window);

    app.run();
}
More examples
Hide additional 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.

Implementors§

source§

impl Object for Window

Available on crate feature ui only.
§

type Handle = WindowHandle