summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/websocket/src/main.rs28
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> {