pub trait App {
// Required methods
fn update(&mut self, msg: Message) -> Option<Command>;
fn view(&self) -> String;
// Provided method
fn init(&self) -> Option<Command> { ... }
}Expand description
The trait your model must implement in order to be run.
init is called once when the model is run for the first time, and optionally returns a Command.
There is a default implementation of init that returns None.
update is called every time your application recieves a Message.
You are allowed to mutate your model’s state in this function.
It optionally returns a Command.
view is called after every update and is responsible for rendering the model.
It returns a String that is printed to the screen.
You are not allowed to mutate the state of your application in the view, only render it.
For examples, check the examples directory.