Trait iced_web::Application[][src]

pub trait Application {
    type Executor: Executor;
    type Message: Send;
    type Flags;
    fn new(flags: Self::Flags) -> (Self, Command<Self::Message>)
    where
        Self: Sized
;
fn title(&self) -> String;
fn update(
        &mut self,
        message: Self::Message,
        clipboard: &mut Clipboard
    ) -> Command<Self::Message>;
fn view(&mut self) -> Element<'_, Self::Message>; fn subscription(&self) -> Subscription<Self::Message> { ... }
fn run(flags: Self::Flags)
    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 Executor: Executor[src]

The Executor that will run commands and subscriptions.

type Message: Send[src]

The type of messages your Application will produce.

type Flags[src]

The data needed to initialize your Application.

Loading content...

Required methods

fn new(flags: Self::Flags) -> (Self, Command<Self::Message>) where
    Self: Sized
[src]

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[src]

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,
    clipboard: &mut Clipboard
) -> Command<Self::Message>
[src]

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>[src]

Returns the widgets to display in the Application.

These widgets can produce messages based on user interaction.

Loading content...

Provided methods

fn subscription(&self) -> Subscription<Self::Message>[src]

Returns the event Subscription for the current state of the application.

A Subscription will be kept alive as long as you keep returning it, and the messages produced will be handled by update.

By default, this method returns an empty Subscription.

fn run(flags: Self::Flags) where
    Self: 'static + Sized
[src]

Runs the Application.

Loading content...

Implementors

Loading content...