Skip to main content

App

Trait App 

pub trait App {
    // Required method
    fn update(&mut self, ctx: &mut dyn AppContext);

    // Provided methods
    fn on_start(&mut self, ctx: &mut dyn AppContext) { ... }
    fn on_exit(&mut self) { ... }
}
Expand description

One application — implements update and gets called once per frame.

Tools should be single types (a struct holding all the app state) implementing this trait. The boot helper instantiates the type once, then drives update for the lifetime of the window.

Required Methods§

fn update(&mut self, ctx: &mut dyn AppContext)

Per-frame update — paint UI, react to input, dispatch async completions, etc.

Provided Methods§

fn on_start(&mut self, ctx: &mut dyn AppContext)

Called once after the backend is up and before the first update. Apps install their theme / fonts / DPI snapping here. Default is a no-op.

fn on_exit(&mut self)

Called once when the window is closing. Persist state here. Default is a no-op.

Implementors§