AppData

Trait AppData 

Source
pub trait AppData: 'static {
    // Required method
    fn handle_messages(&mut self, messages: &mut MessageStack);

    // Provided method
    fn suspended(&mut self) { ... }
}
Expand description

Application state

Kas allows application state to be stored both in the widget tree (in Adapt nodes and user-defined widgets) and by the application root (shared across windows). This trait must be implemented by the latter.

When no top-level data is required, use () which implements this trait.

TODO: should we pass some type of interface to the runner to these methods? We could pass a &mut dyn RunnerT easily, but that trait is not public.

Required Methods§

Source

fn handle_messages(&mut self, messages: &mut MessageStack)

Handle messages

This is the last message handler: it is called when, after traversing the widget tree (see kas::event module doc), a message is left on the stack. Unhandled messages will result in warnings in the log.

Provided Methods§

Source

fn suspended(&mut self)

Application is being suspended

The application should ensure any important state is saved.

This method is called when the application has been suspended or is about to exit (on Android/iOS/Web platforms, the application may resume after this method is called; on other platforms this probably indicates imminent closure). Widget state may still exist, but is not live (widgets will not process events or messages).

Implementations on Foreign Types§

Source§

impl AppData for ()

Source§

fn handle_messages(&mut self, _: &mut MessageStack)

Source§

fn suspended(&mut self)

Implementors§