[][src]Trait iced_web::Application

pub trait Application {
    type Message: Clone;
    fn new() -> (Self, Command<Self::Message>)
    where
        Self: Sized
;
fn title(&self) -> String;
fn update(&mut self, message: Self::Message) -> Command<Self::Message>;
fn view(&mut self) -> Element<Self::Message>; fn run()
    where
        Self: 'static + Sized
, { ... } }

An interactive web application.

This trait is the main entrypoint of Iced. Once implemented, you can run your GUI application by simply calling run. It will take control of the <title> and the <body> of the document.

An Application can execute asynchronous actions by returning a Command in some of its methods.

Associated Types

type Message: Clone

The type of messages your Application will produce.

Loading content...

Required methods

fn new() -> (Self, Command<Self::Message>) where
    Self: Sized

Initializes the Application.

Here is where you should return the initial state of your app.

Additionally, you can return a Command if you need to perform some async action in the background on startup. This is useful if you want to load state from a file, perform an initial HTTP request, etc.

fn title(&self) -> String

Returns the current title of the Application.

This title can be dynamic! The runtime will automatically update the title of your application when necessary.

fn update(&mut self, message: Self::Message) -> Command<Self::Message>

Handles a message and updates the state of the Application.

This is where you define your update logic. All the messages, produced by either user interactions or commands, will be handled by this method.

Any Command returned will be executed immediately in the background.

fn view(&mut self) -> Element<Self::Message>

Returns the widgets to display in the Application.

These widgets can produce messages based on user interaction.

Loading content...

Provided methods

fn run() where
    Self: 'static + Sized

Runs the Application.

Loading content...

Implementors

Loading content...