Add clipboard argument to Application::update

This commit is contained in:
Héctor Ramón Jiménez 2021-03-11 03:38:20 +01:00
parent 7eb5127748
commit ae517b9fa0
18 changed files with 117 additions and 49 deletions

View file

@ -29,7 +29,7 @@ use std::mem::ManuallyDrop;
///
/// When using an [`Application`] with the `debug` feature enabled, a debug view
/// can be toggled by pressing `F12`.
pub trait Application: Program {
pub trait Application: Program<Clipboard = Clipboard> {
/// The data needed to initialize your [`Application`].
type Flags;
@ -257,6 +257,7 @@ async fn run_instance<A, E, C>(
&mut application,
&mut runtime,
&mut debug,
&mut clipboard,
&mut messages,
);
@ -409,13 +410,14 @@ pub fn update<A: Application, E: Executor>(
application: &mut A,
runtime: &mut Runtime<E, Proxy<A::Message>, A::Message>,
debug: &mut Debug,
clipboard: &mut A::Clipboard,
messages: &mut Vec<A::Message>,
) {
for message in messages.drain(..) {
debug.log_message(&message);
debug.update_started();
let command = runtime.enter(|| application.update(message));
let command = runtime.enter(|| application.update(message, clipboard));
debug.update_finished();
runtime.spawn(command);