pub trait ReactPayload:
Event
+ DeserializeOwned
+ TS
+ Send
+ Sync
+ 'static {
const NAME: &'static str;
}Expand description
A typed payload a React emit(NAME, value) call deserializes into.
Usually you don’t implement this by hand — apply #[react_message],
which derives Deserialize and TS and implements both Event and this trait. The
JSON value is deserialized straight into Self, so the payload’s shape must
match what JS emits: emit("count", 5) needs a payload that deserializes from
a number (e.g. struct Count(usize)), while emit("move", { x, y }) needs a struct.
The TS bound lets ReactAppExt::export_react_typescript mirror the payload’s
shape into a TypeScript type, so the JS emit is type-checked against the same struct.
Required Associated Constants§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".