Typed events
Events are emitted on the JSD instance, not on jsd.vision or the other application objects. All payloads are described in the 67-event catalog.
import type { JSDEvents } from '@danidoble/serial-node-jsd';
const onStatus = (...[status]: JSDEvents['vision:machine-status']) => {
console.log(status.machine, status.availabilityToDispense);
};
jsd.on('vision:machine-status', onStatus);
jsd.once('serial:connected', info => console.log(info.path));
// When the consumer is disposed:
jsd.off('vision:machine-status', onStatus);The maps contain argument tuples. Extract one payload using JSDEvents['vision:machine-status'][0], or a listener with (...args: JSDEvents['vision:machine-status']) => void.
| Namespace | Events | Meaning |
|---|---|---|
| serial: | 11 | Session lifecycle, recovery, protocol frames, parser errors |
| vision: | 30 | Machines, channels, dispensing, configuration |
| licensing: | 6 | Features, licenses, seed, identification |
| manifest: | 4 | Log lines and manifest transfer |
| mdbCardHolder: | 16 | Card-holder state, payment, sessions |
Submission versus completion
Awaiting most Promise<void> methods only submits a command to the JSD queue. Subscribe before sending; the device response arrives asynchronously. Neither an ACK nor a resolved submission promise proves a successful dispense or payment.
requestLogs(), assignChannels(), and dispense operations wait for their domain results. These waits do not have built-in deadlines; see recovery.
Listener ownership
Node EventEmitter invokes listeners synchronously. Keep callbacks short, remove only listeners your component owns, and handle rejections inside async callbacks. The custom event serial:error is different from Node's special error event.