summaryrefslogtreecommitdiffstats
path: root/examples/download_progress/src/download.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/download_progress/src/download.rs')
-rw-r--r--examples/download_progress/src/download.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/download_progress/src/download.rs b/examples/download_progress/src/download.rs
index d6cc1e24..bdf57290 100644
--- a/examples/download_progress/src/download.rs
+++ b/examples/download_progress/src/download.rs
@@ -1,4 +1,5 @@
-use iced::subscription;
+use iced::futures;
+use iced::Subscription;
use std::hash::Hash;
@@ -7,9 +8,14 @@ pub fn file<I: 'static + Hash + Copy + Send + Sync, T: ToString>(
id: I,
url: T,
) -> iced::Subscription<(I, Progress)> {
- subscription::unfold(id, State::Ready(url.to_string()), move |state| {
- download(id, state)
- })
+ Subscription::run_with_id(
+ id,
+ futures::stream::unfold(State::Ready(url.to_string()), move |state| {
+ use iced::futures::FutureExt;
+
+ download(id, state).map(Some)
+ }),
+ )
}
async fn download<I: Copy>(id: I, state: State) -> ((I, Progress), State) {