mirror of
https://github.com/bevyengine/bevy
synced 2024-12-19 09:33:06 +00:00
d9b8b3e618
This adds a `EventWriter<T>` `SystemParam` that is just a thin wrapper around `ResMut<Events<T>>`. This is primarily to have API symmetry between the reader and writer, and has the added benefit of easily improving the API later with no breaking changes.
11 lines
356 B
Rust
11 lines
356 B
Rust
use crate::WindowCloseRequested;
|
|
use bevy_app::{AppExit, EventReader, EventWriter};
|
|
|
|
pub fn exit_on_window_close_system(
|
|
mut app_exit_events: EventWriter<AppExit>,
|
|
mut window_close_requested_events: EventReader<WindowCloseRequested>,
|
|
) {
|
|
if window_close_requested_events.iter().next().is_some() {
|
|
app_exit_events.send(AppExit);
|
|
}
|
|
}
|