[−][src]Trait iced_web::Application
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
The Executor that will run commands and subscriptions.
The [executor::WasmBindgen] can be a good choice for the Web.
type Message: Send
The type of messages your Application will produce.
type Flags
The data needed to initialize your Application.
Required methods
fn new(flags: Self::Flags) -> (Self, Command<Self::Message>) where
Self: Sized,
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.
Provided methods
fn subscription(&self) -> Subscription<Self::Message>
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,
Self: 'static + Sized,
Runs the Application.