In particular, components should be able to dispatch events, and subscribers should be able to choose to either consume them or give another subscriber a chance to handle them.
This could look something like...
hooks.use_events<MyEvent>(|e| {
if ... {
// handle the event
e.stop_propagation();
}
});
Somewhere else...
let dispatcher = hooks.use_event_dispatcher<MyEvent>();
dispatcher.dispatch(MyEvent::new(...));
Unless stop_propagate is called on the event, the event would bubble up the chain of parent elements with event handlers for that type.
This mechanism could potentially replace the current use_terminal_events hook, if for keystroke events we also had a mechanism to define a focus or "first responder" to which they would be dispatched initially.
In particular, components should be able to dispatch events, and subscribers should be able to choose to either consume them or give another subscriber a chance to handle them.
This could look something like...
Somewhere else...
Unless
stop_propagateis called on the event, the event would bubble up the chain of parent elements with event handlers for that type.This mechanism could potentially replace the current
use_terminal_eventshook, if for keystroke events we also had a mechanism to define a focus or "first responder" to which they would be dispatched initially.