diff options
author | 2024-03-17 18:40:27 +0100 | |
---|---|---|
committer | 2024-03-17 18:40:27 +0100 | |
commit | acb9321296be9b20899717615e46e039f82c5594 (patch) | |
tree | 5be22dba9755204df587b9be5fba6e0f9f2d2ebc /examples/websocket | |
parent | 78e78d20b6c816b476aec0015a413753aee58725 (diff) | |
download | iced-acb9321296be9b20899717615e46e039f82c5594.tar.gz iced-acb9321296be9b20899717615e46e039f82c5594.tar.bz2 iced-acb9321296be9b20899717615e46e039f82c5594.zip |
Use `Program` API in `websocket` example
Diffstat (limited to 'examples/websocket')
-rw-r--r-- | examples/websocket/src/main.rs | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 47c1898a..460d9a08 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -1,17 +1,17 @@ mod echo; use iced::alignment::{self, Alignment}; -use iced::executor; use iced::widget::{ button, column, container, row, scrollable, text, text_input, }; -use iced::{ - color, Application, Command, Element, Length, Settings, Subscription, Theme, -}; +use iced::{color, Command, Element, Length, Subscription}; use once_cell::sync::Lazy; pub fn main() -> iced::Result { - WebSocket::run(Settings::default()) + iced::program("WebSocket - Iced", WebSocket::update, WebSocket::view) + .load(WebSocket::load) + .subscription(WebSocket::subscription) + .run() } #[derive(Default)] @@ -29,21 +29,9 @@ enum Message { Server, } -impl Application for WebSocket { - type Message = Message; - type Theme = Theme; - type Flags = (); - type Executor = executor::Default; - - fn new(_flags: Self::Flags) -> (Self, Command<Message>) { - ( - Self::default(), - Command::perform(echo::server::run(), |_| Message::Server), - ) - } - - fn title(&self) -> String { - String::from("WebSocket - Iced") +impl WebSocket { + fn load() -> Command<Message> { + Command::perform(echo::server::run(), |_| Message::Server) } fn update(&mut self, message: Message) -> Command<Message> { |