pub struct UiWaker(/* private fields */);Expand description
Rebuilds the UI from any thread, when background work has something to show.
Get one with BuildCx::ui_waker and move it to
the thread. Send the result through a channel and call UiWaker::wake; the
next build runs on the UI thread and reads the channel. Between wakes the app
stays asleep, so there is nothing to poll.
use std::sync::mpsc::channel;
use ravenrs_widgets::{BuildCx, NodeId, View};
struct Pump;
impl View for Pump {
fn build(&self, cx: &mut BuildCx<'_>) -> NodeId {
let waker = cx.ui_waker();
let (send, _receive) = channel();
std::thread::spawn(move || {
let _ = send.send(21 * 2);
waker.wake();
});
cx.empty()
}
}The web build has no other threads to wake it from; there, change a
State as usual.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UiWaker
impl !UnwindSafe for UiWaker
impl Freeze for UiWaker
impl Send for UiWaker
impl Sync for UiWaker
impl Unpin for UiWaker
impl UnsafeUnpin for UiWaker
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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