Expand description
The EventLoop and associated structures.
There are three main differences between EventLoops here and in winit:
- Instead of
runorrun_return, there areblock_onandblock_on_return, which take a future and run it to completion. Eent handling is done through theHandlerstructures instead. - Methods on
EventLoopandEventLoopWindowTargetareasync. - There is no
EventLoopProxytype, since it is now obsolete withasyncblocks. Instead, consider using an async channel to communicate with the event loop.
use async_winit::event_loop::EventLoop;
use async_winit::ThreadUnsafe;
struct MyCustomType;
let (sender, receiver) = async_channel::unbounded();
EventLoop::<ThreadUnsafe>::new().block_on(async move {
// Wait for a message from the channel.
let message = receiver.recv().await.unwrap();
});
// In another thread, send a message to the event loop.
sender.send(MyCustomType).await.unwrap();Structs§
- Event
Loop - Provides a way to retrieve events from the system and from the windows that were registered to the events loop.
- Event
Loop Builder - Object that allows for building the
EventLoop. - Event
Loop Closed - The error that is returned when an
EventLoopProxyattempts to wake up anEventLoopthat no longer exists. - Event
Loop Window Target - A reference to the
EventLoopthat allows the user access to the underlying display connections. - Wakeup
- Used to indicate that we need to wake up the event loop.
Enums§
- Control
Flow - Set by the user callback given to the
EventLoop::runmethod. - Device
Event Filter - Filter controlling the propagation of device events.