Use Task::discard in websocket example
This commit is contained in:
parent
629e795784
commit
714c4982d6
2 changed files with 5 additions and 10 deletions
|
|
@ -30,7 +30,6 @@ pub fn connect() -> impl Sipper<Never, Event> {
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(1))
|
tokio::time::sleep(tokio::time::Duration::from_secs(1))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
output.send(Event::Disconnected).await;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
mod echo;
|
mod echo;
|
||||||
|
|
||||||
use iced::futures::stream;
|
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, center, column, operation, row, scrollable, text, text_input,
|
button, center, column, operation, row, scrollable, text, text_input,
|
||||||
};
|
};
|
||||||
|
|
@ -23,7 +22,6 @@ enum Message {
|
||||||
NewMessageChanged(String),
|
NewMessageChanged(String),
|
||||||
Send(echo::Message),
|
Send(echo::Message),
|
||||||
Echo(echo::Event),
|
Echo(echo::Event),
|
||||||
Server,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebSocket {
|
impl WebSocket {
|
||||||
|
|
@ -34,7 +32,10 @@ impl WebSocket {
|
||||||
new_message: String::new(),
|
new_message: String::new(),
|
||||||
state: State::Disconnected,
|
state: State::Disconnected,
|
||||||
},
|
},
|
||||||
operation::focus_next(),
|
Task::batch([
|
||||||
|
Task::future(echo::server::run()).discard(),
|
||||||
|
operation::focus_next(),
|
||||||
|
]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,16 +77,11 @@ impl WebSocket {
|
||||||
operation::snap_to_end(MESSAGE_LOG)
|
operation::snap_to_end(MESSAGE_LOG)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::Server => Task::none(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Message> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
Subscription::batch([
|
Subscription::run(echo::connect).map(Message::Echo)
|
||||||
Subscription::run(|| stream::once(echo::server::run()))
|
|
||||||
.map(|_| Message::Server),
|
|
||||||
Subscription::run(echo::connect).map(Message::Echo),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&self) -> Element<'_, Message> {
|
fn view(&self) -> Element<'_, Message> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue