bevy/crates/bevy_window/src/system.rs
TheRawMeatball d9b8b3e618 Add EventWriter (#1575)
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.
2021-03-07 20:42:04 +00:00

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);
}
}