Trait winit::platform::web::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);
}
Available on web_platform only.
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.

Object Safety§

This trait is not object safe.

Implementors§