Enable tester feature in websocket example

This commit is contained in:
Héctor Ramón Jiménez 2025-06-03 09:54:14 +02:00
parent 1821dc7ff0
commit 9cd1a93e5a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 44 additions and 16 deletions

View file

@ -1,9 +1,11 @@
mod echo;
use iced::futures::stream;
use iced::widget::{
self, button, center, column, row, scrollable, text, text_input,
};
use iced::{Center, Element, Fill, Subscription, Task, color};
use std::sync::LazyLock;
pub fn main() -> iced::Result {
@ -34,10 +36,7 @@ impl WebSocket {
new_message: String::new(),
state: State::Disconnected,
},
Task::batch([
Task::perform(echo::server::run(), |_| Message::Server),
widget::focus_next(),
]),
widget::focus_next(),
)
}
@ -87,7 +86,11 @@ impl WebSocket {
}
fn subscription(&self) -> Subscription<Message> {
Subscription::run(echo::connect).map(Message::Echo)
Subscription::batch([
Subscription::run(|| stream::once(echo::server::run()))
.map(|_| Message::Server),
Subscription::run(echo::connect).map(Message::Echo),
])
}
fn view(&self) -> Element<Message> {