Command.begin Event

The begin event fires when activation of a command begins. This is the proper way to run code in response to discrete input event.

Event type

The event uses the CommandEvent object, with the phase set to "begin".

Example

> ident = simulator.findCommand("sim/transponder/transponder_ident")
Command{ name: "sim/transponder/transponder_ident" }
> ident.addEventListener("begin", (event) => { console.log(`Received command event with phase {event.phase}`)})
undefined
> ident.begin()
Received command event with phase begin
undefined
> ident.end()
undefined

References