pub trait ViewModel: Send + 'static {
// Provided methods
fn on_open(&mut self, cx: &mut Cx<'_, Self>)
where Self: Sized { ... }
fn on_close(&mut self, cx: &mut Cx<'_, Self>)
where Self: Sized { ... }
fn on_back(&mut self, cx: &mut Cx<'_, Self>) -> bool
where Self: Sized { ... }
fn customize(&self, root: &mut Widget) { ... }
}Expand description
A screen’s state and logic. Implement it (often with no methods) for the
type named by the .yui file’s x:ViewModel.
All hooks run on the render thread with the screen locked; use
Cx to close the screen, navigate, or get a ScreenHandle for
updates from other threads.
Provided Methods§
Sourcefn on_open(&mut self, cx: &mut Cx<'_, Self>)where
Self: Sized,
fn on_open(&mut self, cx: &mut Cx<'_, Self>)where
Self: Sized,
The screen was opened (every time).
Sourcefn on_close(&mut self, cx: &mut Cx<'_, Self>)where
Self: Sized,
fn on_close(&mut self, cx: &mut Cx<'_, Self>)where
Self: Sized,
The screen was closed (by any path).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".