Skip to main content

MultiEventReactor

Derive Macro MultiEventReactor 

Source
#[derive(MultiEventReactor)]
{
    // Attributes available to this derive:
    #[batpak]
}
Expand description

Derives batpak::event::MultiReactive<Input> for a named-field struct, for use with Store::react_loop_multi (JSON) or Store::react_loop_multi_raw (msgpack).

Syntax mirrors #[derive(EventSourced)]:

  • #[batpak(input = <Lane>)] — required, once. Lane is either JsonValueInput or RawMsgpackInput.
  • #[batpak(event = <Payload>, handler = <fn>)] — one per bound payload type. At least one is required. event = T requires T to be a single-segment path (bring the type into scope with use if needed). This ensures the derive can dedupe event bindings without running full path resolution.

Generates a MultiReactive<Input> impl whose dispatch body matches on event.header.event_kind, uses DecodeTyped::route_typed per arm, calls the matching handler, and returns MultiDispatchError::Decode on matched-kind decode failure (unified contract with TypedReactive<T>). Unbound kinds fall through as Ok(()) — silent filter.