feat(task): add stream function
This commit is contained in:
parent
cb6ea4c7c3
commit
77c3a8ed90
2 changed files with 9 additions and 0 deletions
|
|
@ -106,6 +106,7 @@ cosmic-config = { path = "cosmic-config" }
|
||||||
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
|
cosmic-settings-daemon = { git = "https://github.com/pop-os/dbus-settings-bindings", optional = true }
|
||||||
css-color = "0.2.5"
|
css-color = "0.2.5"
|
||||||
derive_setters = "0.1.5"
|
derive_setters = "0.1.5"
|
||||||
|
futures = "0.3"
|
||||||
image = { version = "0.25.5", default-features = false, features = [
|
image = { version = "0.25.5", default-features = false, features = [
|
||||||
"jpeg",
|
"jpeg",
|
||||||
"png",
|
"png",
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
//! Create asynchronous actions to be performed in the background.
|
//! Create asynchronous actions to be performed in the background.
|
||||||
|
|
||||||
|
use futures::stream::{Stream, StreamExt};
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
/// Yields a task which contains a batch of tasks.
|
/// Yields a task which contains a batch of tasks.
|
||||||
|
|
@ -23,3 +24,10 @@ pub fn future<X: Into<Y>, Y: 'static>(
|
||||||
pub fn message<X: Send + 'static + Into<Y>, Y: 'static>(message: X) -> iced::Task<Y> {
|
pub fn message<X: Send + 'static + Into<Y>, Y: 'static>(message: X) -> iced::Task<Y> {
|
||||||
future(async move { message.into() })
|
future(async move { message.into() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Yields a task which will run a stream on the runtime executor.
|
||||||
|
pub fn stream<X: Into<Y> + 'static, Y: 'static>(
|
||||||
|
stream: impl Stream<Item = X> + Send + 'static,
|
||||||
|
) -> iced::Task<Y> {
|
||||||
|
iced::Task::stream(stream.map(Into::into))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue