Replace Command with a new Task API with chain support

This commit is contained in:
Héctor Ramón Jiménez 2024-06-14 01:47:39 +02:00
parent e6d0b3bda5
commit a25b1af456
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
74 changed files with 1351 additions and 1767 deletions

View file

@ -1,5 +1,5 @@
use iced::widget::{button, center, column, text};
use iced::{system, Command, Element};
use iced::{system, Element, Task};
pub fn main() -> iced::Result {
iced::program("System Information - Iced", Example::update, Example::view)
@ -24,19 +24,20 @@ enum Message {
}
impl Example {
fn update(&mut self, message: Message) -> Command<Message> {
fn update(&mut self, message: Message) -> Task<Message> {
match message {
Message::Refresh => {
*self = Self::Loading;
return system::fetch_information(Message::InformationReceived);
return system::fetch_information()
.map(Message::InformationReceived);
}
Message::InformationReceived(information) => {
*self = Self::Loaded { information };
}
}
Command::none()
Task::none()
}
fn view(&self) -> Element<Message> {