diff options
Diffstat (limited to 'src/application.rs')
-rw-r--r-- | src/application.rs | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/application.rs b/src/application.rs index 5d16b40f..d0f77304 100644 --- a/src/application.rs +++ b/src/application.rs @@ -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: FnOnce() -> (P::State, Task<P::Message>) + '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, @@ -435,6 +417,15 @@ pub trait Update<State, Message> { ) -> impl Into<Task<Message>>; } +impl<State, Message> Update<State, Message> for () { + fn update( + &self, + _state: &mut State, + _message: Message, + ) -> impl Into<Task<Message>> { + } +} + impl<T, State, Message, C> Update<State, Message> for T where T: Fn(&mut State, Message) -> C, |