From acb9321296be9b20899717615e46e039f82c5594 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 17 Mar 2024 18:40:27 +0100 Subject: Use `Program` API in `websocket` example --- examples/websocket/src/main.rs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'examples/websocket/src') 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) { - ( - Self::default(), - Command::perform(echo::server::run(), |_| Message::Server), - ) - } - - fn title(&self) -> String { - String::from("WebSocket - Iced") +impl WebSocket { + fn load() -> Command { + Command::perform(echo::server::run(), |_| Message::Server) } fn update(&mut self, message: Message) -> Command { -- cgit