API · Core

Events

Observe lifecycle boundaries using the Node-compatible event API available in every runtime.

Methods

on(event: string | symbol, listener: (...args: any[]) => void): this
once(event: string | symbol, listener: (...args: any[]) => void): this
off(event: string | symbol, listener: (...args: any[]) => void): this
emit(event: string | symbol, ...args: any[]): boolean
listenerCount(event: string | symbol): number
eventNames(): Array<string | symbol>
removeAllListeners(event?: string | symbol): this
setMaxListeners(count: number): this

Node uses its native event base. Browser builds provide the same listed surface; setMaxListeners() is a chainable no-op there. once() listeners can be removed with the original callback. emit() returns whether listeners existed. An unhandled browser 'error' event throws, matching Node’s important behavior.

Exstream events

EventArgumentsWhen
errorerrorA record error has no downstream handler/consumer, or an abort/fatal reason is observed by a registered listener
fatalerror, inputfail() propagates a non-recoverable graph failure
abortreasonState transitions to aborted
endnoneReadable stream reaches any terminal state
drainnoneWritable root can accept production again

Platform adapters can also surface familiar events such as finish or close. Terminal cleanup removes stream listeners, so register lifecycle observers before consumption begins. Events are synchronous; throwing listeners can interrupt their caller.

stream state, abort(), write(), errors()