Skip to main content

react_event

Attribute Macro react_event 

Source
#[react_event]
Expand description

Turn a struct into a typed React event payload (a Bevy → React broadcast).

Derives serde::Serialize + ts_rs::TS and implements [bevy_react::ReactEvent]. Send it from a system with the ReactEvents param; React listens with bevy.on(name, cb). Register the type with App::add_react_event::<E>() so it appears in the generated typings.

The name defaults to the struct ident with its first letter lowercased.

#[react_event(name = "user.disconnected")]
struct UserDisconnected { user_id: String }