Skip to content

smelt.events

Availability: Everywhere, including headless mode.

Occurrence-oriented subscriptions for events such as turn_start, tool_start, and turn_complete. Events have no current value and handlers receive only the payload. Use smelt.signal for state whose current value matters. Passing a state signal name to smelt.events raises an error.

smelt.events.emit

fun(event: smelt.events.Name, payload: any): nil

Types: smelt.events.Name

Publish payload for the event named event. Custom events are declared automatically on first emit.

smelt.events.new

fun(event: smelt.events.Name): nil

Types: smelt.events.Name

Declare an event named event. An existing event is left unchanged. smelt.events.on and smelt.events.emit also declare custom events automatically, so this is only needed when a plugin wants to document its event surface explicitly.

smelt.events.on

fun(event: smelt.events.Name, handler: fun(value: any)): smelt.Reg

Types: smelt.events.Name, smelt.Reg

Register handler(payload) for the event named event. Custom events are declared automatically before subscribing. Returns a Reg whose :remove() unsubscribes.