Skip to content

Commit adc3671

Browse files
committed
Add docs
1 parent e5a253b commit adc3671

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

crates/bevy_ecs/src/event.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{fmt, hash::Hash, iter::Chain, marker::PhantomData, slice::Iter};
1111
///
1212
/// Events must be thread-safe.
1313
pub trait Event: Send + Sync + 'static {
14+
/// Whether a warning is emitted if an event is sent but never read
1415
const WARN_MISSED: bool = false;
1516
}
1617

@@ -126,6 +127,15 @@ struct EventInstance<E: Event> {
126127
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/ecs/event.rs)
127128
/// [Example usage standalone.](https://github.com/bevyengine/bevy/blob/latest/crates/bevy_ecs/examples/events.rs)
128129
///
130+
/// # Missed events
131+
///
132+
/// Obscure bugs may arise if an [`EventReader`] does not read all events before they are cleared.
133+
/// To emit a warning when this happens, annotate the event with `#[event(warn_missed)]`.
134+
/// ```
135+
/// #[derive(Event)]
136+
/// #[event(warn_missed)]
137+
/// struct MyEvent;
138+
/// ```
129139
#[derive(Debug, Resource)]
130140
pub struct Events<E: Event> {
131141
/// Holds the oldest still active events.

0 commit comments

Comments
 (0)