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.

Next steps