Skip to content

module

window

Window events for templates' @event: handler declarations (@resize: measure, @keydown: press(event.key)).

The browser installs a listener that uses window.addEventListener. Without one, listeners wait in a list that only dispatch calls: prerendering never does, so no window handler runs at build time, and tests send the events they need.

Functions

dispatch

pub fn dispatch(event: &Event)

Send event to the window listeners waiting for its kind, as the browser would. Does nothing to a browser's listeners.

listen

pub fn listen(kind: &str, handler: Handler) -> Cancel

Call handler for each window event of kind until cancelled.

pending

pub fn pending() -> usize

How many window listeners are waiting (without a browser).

set_host

pub fn set_host(listen: Listen)

Set what listens for window events (the browser does, when the app starts).

Type aliases

Listen

pub type Listen = Rc<dyn Fn(&str, Handler) -> Cancel>;

Listens for a window event ("resize") until the returned Cancel runs.