Skip to main content

react_request

Attribute Macro react_request 

Source
#[react_request]
Expand description

Turn a struct into a typed React request payload (a React → Bevy call that awaits a typed reply).

Derives serde::Deserialize + ts_rs::TS and implements [bevy_react::ReactRequest], so the type can be registered with App::add_react_request_handler and answered from a React request(name, value) call. Observe On<Request<T>> and reply with req.respond(value).

The response type is required and points at a type you define separately and derive serde::Serialize + ts_rs::TS on. The name defaults to the struct ident with its first letter lowercased; use a dotted name to get a nested proxy (#[react_request(name = "board.get", ...)]bevy.board.get).

#[react_request(name = "board.get", response = Board)]
struct BoardGet;                // unit payload → `bevy.board.get()` takes no args

#[react_request(name = "pieces.move", response = MoveStatus)]
struct PiecesMove { piece: String, to: String }