DispatchEffect
A cross-component dispatch effect: a component's `handle()` DECLARES that a browser event is delivered to ANOTHER component, which reacts client-side — no re-render, no imperative JS (greenhouse decisions/0189). Where {@see RenderEffect} re-paints the target, this one SIGNALS it: the client dispatches a `milpa:<event>` CustomEvent (with the payload as its `detail`) on the target component's root. The target listens with `x-on:milpa:<event>` (Alpine) or a plain listener and updates itself. Use it when the other component should react (open, highlight, refetch) without the server re-rendering it.
DispatchEffect::__construct()
public function __construct(string $to, string $event, array $payload = []):Parameters
| Name | Type | Description |
|---|---|---|
| $to | string | the componentId of the component to notify |
| $event | string | the event name (delivered as `milpa:<event>`) |
| $payload | array<string, mixed> | the event detail |
DispatchEffect::toArray()
public function toArray(): arrayThe effect as the array that travels in {@see \Milpa\Live\ValueObjects\InteractionResult::$effects}.