winit/src/platform_impl/web/event_loop/proxy.rs

20 lines
431 B
Rust
Raw Normal View History

2019-06-25 03:15:34 +02:00
use super::runner;
use crate::event::Event;
use crate::event_loop::EventLoopClosed;
#[derive(Clone)]
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(())
}
}