Files
winit/src/platform_impl/web/event_loop/proxy.rs
2019-09-24 19:41:59 -04:00

27 lines
558 B
Rust

use super::runner;
use crate::event::Event;
use crate::event_loop::EventLoopClosed;
pub struct Proxy<T: 'static> {
runner: runner::Shared<T>,
}
impl<T: 'static> Proxy<T> {
pub fn new(runner: runner::Shared<T>) -> Self {
Proxy { runner }
}
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
self.runner.send_event(Event::UserEvent(event));
Ok(())
}
}
impl<T: 'static> Clone for Proxy<T> {
fn clone(&self) -> Self {
Proxy {
runner: self.runner.clone(),
}
}
}