Skip to content

Commit 1e5c1ad

Browse files
committed
Avoid using Message to drive logic in system_information example
1 parent 334f5ba commit 1e5c1ad

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • examples/system_information/src

examples/system_information/src/main.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,27 @@ enum Message {
2929

3030
impl Example {
3131
fn new() -> (Self, Task<Message>) {
32-
(Self::Loading, Task::done(Message::Refresh))
32+
(
33+
Self::Loading,
34+
system::fetch_information().map(Message::InformationReceived),
35+
)
3336
}
34-
37+
3538
fn update(&mut self, message: Message) -> Task<Message> {
3639
match message {
3740
Message::Refresh => {
38-
*self = Self::Loading;
41+
let (state, refresh) = Self::new();
42+
43+
*self = state;
3944

40-
return system::fetch_information()
41-
.map(Message::InformationReceived);
45+
refresh
4246
}
4347
Message::InformationReceived(information) => {
4448
*self = Self::Loaded { information };
49+
50+
Task::none()
4551
}
4652
}
47-
48-
Task::none()
4953
}
5054

5155
fn view(&self) -> Element<Message> {

0 commit comments

Comments
 (0)