Skip to main content

react_message

Attribute Macro react_message 

Source
#[react_message]
Expand description

Turn a struct into a typed React message payload.

Applying #[react_message] derives serde::Deserialize and ts_rs::TS and implements both bevy::ecs::event::Event and bevy_react::ReactPayload, so the type can be registered with App::add_react_handler / add_react_message, routed from a React emit(name, value) call, and exported to TypeScript via App::export_react_typescript.

The emit name defaults to the struct name with its first letter lowercased (Count"count", PlayerScore"playerScore"); override it with #[react_message(name = "...")].

#[react_message]
struct Count(usize);            // name = "count"

#[react_message(name = "hp")]
struct Health(u32);             // name = "hp"