From 8bc49cd88653309f5abe8a38d5a4af36fcfea933 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 5 Jul 2024 02:15:13 +0200 Subject: Hide `Subscription` internals .. and introduce `stream::channel` helper --- examples/download_progress/src/download.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'examples/download_progress') 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( 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(id: I, state: State) -> ((I, Progress), State) { -- cgit