seed
seed copied to clipboard
Use gloo_events::EventListener
gloo_events looks like it would make sense in seed as a replacement for some of seed's event management code. Seed is already using gloo_timers and gloo_file, and seed has a stated intention to incorporate gloo crates as they become available.
From a quick look through seed, this would result in:
-
seed::virtual_dom::event_handler_manager::listener:Listener
being a little simpler but still keeping it's job of aggregating event handlers and dispatching resulting messages. -
seed::app::streams::event_stream::EventStream
being simpler (maybe very simple) -
seed::browser::service::routing
will have simpler event handling code
Other considerations:
passive
passive
is true
by default in gloo_events, that would need to be switched false
in seed in ev!
and raw_ev!
in order to use Event.prevent_default
(other event macros that don't provide access to web_sys::Event
would be passive. This will lead to bad performance in the case of an app intercepting scroll events that use one of these macros
- automatically set
passive = true
for scroll events and leavepassive = false
for others; matching the defaults that browsers use (and matching what seed would provide today, but would mean that seed would need to specify which events default topassive = true
rather than the browser) - provide a
passive_ev!
or similar macro for high performance events withpassive = true
,ev!
andraw_ev!
would bepassive = false
I would like to resolve event API design first: https://github.com/seed-rs/seed/issues/331 (we can integrate passive
behavior/switch into it somehow).
And then we can focus on implementation details, i.e. rewriting into gloo_events.
So I recommend to leave this issue open and return back once new event API is designed/implemented.