diff options
author | 2024-07-05 02:34:39 +0200 | |
---|---|---|
committer | 2024-07-05 02:34:39 +0200 | |
commit | 978327f9e7f68d3e5bc280faa0617487d8eabc57 (patch) | |
tree | e0ea35f42d41568a792b0b22eb119226908cb6a7 /examples/download_progress/src | |
parent | e50aa03edc858d561992d8ca441aa063f273eeac (diff) | |
parent | c9e0ed7ca4a7fce23450b9aeba6eb79244832521 (diff) | |
download | iced-978327f9e7f68d3e5bc280faa0617487d8eabc57.tar.gz iced-978327f9e7f68d3e5bc280faa0617487d8eabc57.tar.bz2 iced-978327f9e7f68d3e5bc280faa0617487d8eabc57.zip |
Merge pull request #2493 from iced-rs/hide-subscription-internals
Hide `Subscription` internals
Diffstat (limited to 'examples/download_progress/src')
-rw-r--r-- | examples/download_progress/src/download.rs | 14 |
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) { |