pub fn listen_desktop_events<T, S>(
    sender: S
) -> Result<DesktopEventThread, Error>
where T: From<DesktopEvent> + Clone + Send + 'static, S: Into<DesktopEventSender<T>> + Clone,
Expand description

Create event sending thread, give this crossbeam_channel::Sender<T>, winit::event_loop::EventLoopProxy<T>, or std::sync::mpsc::Sender<T>.

DesktopEvent must be convertible to your message type T.

This function returns DesktopEventThread, which must be kept alive. When the value is dropped the listener is closed and thread joined.

§Example

let (tx, rx) = std::sync::mpsc::channel::<DesktopEvent>();
let _notifications_thread = listen_desktop_events(tx);
// Do with receiver something
for item in rx {
   println!("{:?}", item);
}
// When `_notifications_thread` is dropped the thread is joined and listener closed.

Additionally you can pass crossbeam-channel sender, or winit eventloop proxy to the function.