Open alice-i-cecile opened 7 months ago
Note that in some cases, I simply can't add a From
impl between the event types: orphan rules block implementations on e.g. AppExit
.
fn send_default_event<E: Event + Default>() -> Self {
On::run(|mut event_writer: EventWriter<E>| {
event_writer.send_default();
})
}
A working prototype of 3.
We could do all three things with a single closure version:
send_event<F: Event>(impl FnMut(E)-> F>)
send_event(move |_| my_other_event.clone())
send_event(MyEvent::from)
send_event(|_| MyEvent::default)
This is the current signature of
On::send_event
.However, I want to be able to quickly do things like "send an
AppExit
event when this button is clicked".I propose three related methods:
send_event
: takes an event of typeF
and captures it in the closure.convert_and_send_event
: current behavior: converts E to F and sends it.send_default_event
: sends an event with theDefault
value.