Remove load method from application and daemon

If you need to run a `Task` during boot, use
`run_with` instead!
This commit is contained in:
Héctor Ramón Jiménez 2024-07-09 00:28:40 +02:00
parent 3d99da805d
commit e86920be5b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
10 changed files with 70 additions and 197 deletions

View file

@ -103,10 +103,6 @@ where
type Renderer = Renderer;
type Executor = iced_futures::backend::default::Executor;
fn load(&self) -> Task<Self::Message> {
Task::none()
}
fn update(
&self,
state: &mut Self::State,
@ -166,14 +162,14 @@ impl<P: Program> Application<P> {
Self: 'static,
P::State: Default,
{
self.run_with(P::State::default)
self.raw.run(self.settings, Some(self.window))
}
/// Runs the [`Application`] with a closure that creates the initial state.
pub fn run_with<I>(self, initialize: I) -> Result
where
Self: 'static,
I: Fn() -> P::State + Clone + 'static,
I: Fn() -> (P::State, Task<P::Message>) + Clone + 'static,
{
self.raw
.run_with(self.settings, Some(self.window), initialize)
@ -323,20 +319,6 @@ impl<P: Program> Application<P> {
}
}
/// Runs the [`Task`] produced by the closure at startup.
pub fn load(
self,
f: impl Fn() -> Task<P::Message>,
) -> Application<
impl Program<State = P::State, Message = P::Message, Theme = P::Theme>,
> {
Application {
raw: program::with_load(self.raw, f),
settings: self.settings,
window: self.window,
}
}
/// Sets the subscription logic of the [`Application`].
pub fn subscription(
self,