Allow specifying a custom executor

This commit is contained in:
mtkennerly 2024-09-18 01:27:35 -04:00
parent f897442831
commit f9ee3229c1
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
2 changed files with 92 additions and 0 deletions

View file

@ -30,6 +30,8 @@
//! ]
//! }
//! ```
use iced_futures::Executor;
use crate::program::{self, Program};
use crate::window;
use crate::{Element, Font, Result, Settings, Size, Subscription, Task};
@ -376,6 +378,22 @@ impl<P: Program> Application<P> {
window: self.window,
}
}
/// Sets the executor of the [`Application`].
pub fn executor<E>(
self,
) -> Application<
impl Program<State = P::State, Message = P::Message, Theme = P::Theme>,
>
where
E: Executor,
{
Application {
raw: program::with_executor::<P, E>(self.raw),
settings: self.settings,
window: self.window,
}
}
}
/// The title logic of some [`Application`].