View all results

Dispatch Expressions

A DISPATCH expression emits an event to a value. It is used to drive the outside world — for example, to fire a click or input event on a browser element.

example.fql
read-only
DISPATCH "click" IN element

DISPATCH is performed for its effect, not its value: it runs synchronously and always evaluates to NONE.

Payload and options

The WITH clause attaches a payload to the event, and the OPTIONS clause carries settings that describe how the event should be emitted.

example.fql
read-only
DISPATCH "input" IN element WITH "hello" DISPATCH "select" IN element WITH ["1", "2"] OPTIONS { selector: "#a", delay: 50 }

The event name can be a literal string, a variable, or a bind parameter.

example.fql
read-only
LET eventName = "hover" DISPATCH eventName IN element

Arrow shorthand

For an event with no payload or options, the arrow operator <- is a concise alternative. The target is on the left and the event name on the right.

example.fql
read-only
element <- "focus"

The two forms are equivalent. Like the long form, the shorthand evaluates to NONE, so it can appear anywhere an expression is allowed — including inside a MATCH arm or a function body.

A host capability

DISPATCH only works when the target value can receive events — it must be a dispatchable value provided by a module or the host application, such as a browser element. Dispatching to a value that does not support it fails at runtime. See Value Capabilities and Host Values.

To wait for events instead of emitting them, see Waitfor Expressions.