diff options
author | 2019-11-24 19:15:28 +0100 | |
---|---|---|
committer | 2019-11-24 19:15:28 +0100 | |
commit | bbcd16c3358e641b8ab1877b802d1f7c5709943d (patch) | |
tree | 72c805ce46792f3c038d2d7ea127263ae965a779 /src | |
parent | 700390bdb297a5fc2eb356b10f9ed2656cc75daa (diff) | |
parent | 2b2a0f12c75032453fbefd2491d3ef51ff0ba88e (diff) | |
download | iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.tar.gz iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.tar.bz2 iced-bbcd16c3358e641b8ab1877b802d1f7c5709943d.zip |
Merge pull request #66 from hecrj/feature/new-web-tour
Make `tour` work with `iced_web` again
Diffstat (limited to 'src')
-rw-r--r-- | src/application.rs | 20 | ||||
-rw-r--r-- | src/sandbox.rs | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/application.rs b/src/application.rs index 5ecb901e..f6d3fb90 100644 --- a/src/application.rs +++ b/src/application.rs @@ -83,7 +83,7 @@ pub trait Application: Sized { /// The type of __messages__ your [`Application`] will produce. /// /// [`Application`]: trait.Application.html - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Send + Clone; /// Initializes the [`Application`]. /// @@ -140,7 +140,7 @@ pub trait Application: Sized { <Instance<Self> as iced_winit::Application>::run(); #[cfg(target_arch = "wasm32")] - iced_web::Application::run(Instance(self)); + <Instance<Self> as iced_web::Application>::run(); } } @@ -180,11 +180,21 @@ where { type Message = A::Message; - fn update(&mut self, message: Self::Message) { - self.0.update(message); + fn new() -> (Self, Command<A::Message>) { + let (app, command) = A::new(); + + (Instance(app), command) } - fn view(&mut self) -> Element<Self::Message> { + fn title(&self) -> String { + self.0.title() + } + + fn update(&mut self, message: Self::Message) -> Command<Self::Message> { + self.0.update(message) + } + + fn view(&mut self) -> Element<'_, Self::Message> { self.0.view() } } diff --git a/src/sandbox.rs b/src/sandbox.rs index 698578f4..60e3be14 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -81,7 +81,7 @@ pub trait Sandbox { /// The type of __messages__ your [`Sandbox`] will produce. /// /// [`Sandbox`]: trait.Sandbox.html - type Message: std::fmt::Debug + Send; + type Message: std::fmt::Debug + Send + Clone; /// Initializes the [`Sandbox`]. /// |