rio_window::platform::web

Trait EventLoopExtWebSys

Source
pub trait EventLoopExtWebSys {
    type UserEvent: 'static;

    // Required methods
    fn spawn_app<A: ApplicationHandler<Self::UserEvent> + 'static>(self, app: A);
    fn spawn<F>(self, event_handler: F)
       where F: 'static + FnMut(Event<Self::UserEvent>, &ActiveEventLoop);
}
Expand description

Additional methods on EventLoop that are specific to the web.

Required Associated Types§

Source

type UserEvent: 'static

A type provided by the user that can be passed through Event::UserEvent.

Required Methods§

Source

fn spawn_app<A: ApplicationHandler<Self::UserEvent> + 'static>(self, app: A)

Initializes the winit event loop.

Unlike run_app() 1, this returns immediately, and doesn’t throw an exception in order to satisfy its ! return type.

Once the event loop has been destroyed, it’s possible to reinitialize another event loop by calling this function again. This can be useful if you want to recreate the event loop while the WebAssembly module is still loaded. For example, this can be used to recreate the event loop when switching between tabs on a single page application.


  1. run_app() is not available on WASM when the target supports exception-handling

Source

fn spawn<F>(self, event_handler: F)
where F: 'static + FnMut(Event<Self::UserEvent>, &ActiveEventLoop),

👎Deprecated: use EventLoopExtWebSys::spawn_app

See spawn_app.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§