Introduce Task::map_with
This commit is contained in:
parent
06ece6a8c3
commit
9f21eae152
5 changed files with 55 additions and 11 deletions
|
|
@ -52,7 +52,7 @@ impl Example {
|
|||
|
||||
let task = download.start();
|
||||
|
||||
task.map(move |update| Message::DownloadUpdated(index, update))
|
||||
task.map_with(index, Message::DownloadUpdated)
|
||||
}
|
||||
Message::DownloadUpdated(id, update) => {
|
||||
if let Some(download) =
|
||||
|
|
|
|||
|
|
@ -94,17 +94,15 @@ impl Gallery {
|
|||
return Task::none();
|
||||
};
|
||||
|
||||
Task::batch(vec![
|
||||
Task::perform(
|
||||
Task::batch([
|
||||
Task::future(
|
||||
image.clone().blurhash(Preview::WIDTH, Preview::HEIGHT),
|
||||
move |result| Message::BlurhashDecoded(id, result),
|
||||
),
|
||||
Task::perform(
|
||||
image.download(Size::Thumbnail {
|
||||
width: Preview::WIDTH,
|
||||
}),
|
||||
move |result| Message::ThumbnailDownloaded(id, result),
|
||||
),
|
||||
)
|
||||
.map_with(id, Message::BlurhashDecoded),
|
||||
Task::future(image.download(Size::Thumbnail {
|
||||
width: Preview::WIDTH,
|
||||
}))
|
||||
.map_with(id, Message::ThumbnailDownloaded),
|
||||
])
|
||||
}
|
||||
Message::ImageDownloaded(Ok(rgba)) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue