事件
EventOptions
Section titled “EventOptions”ctx.on() 和 ctx.once() 接受的选项。
/** Options accepted by `ctx.on()` and `ctx.once()`. */interface EventOptions { /** Add the listener before existing listeners for the same event. */ prepend?: boolean /** Receive the event regardless of context filter checks. */ global?: boolean}DispatchMode
Section titled “DispatchMode”事件服务使用的事件分发策略。
emit 运行同步监听器但不等待它们,parallel 同时等待所有监听器,serial 依次等待监听器直至其中一个提前终止分发,bail 遇到第一个同步提前终止值时停止,waterfall 则围绕最终的 next 回调组合监听器。
/** * Event dispatch strategy used by the event service. * * `emit` runs synchronous listeners without awaiting them, `parallel` awaits * all listeners together, `serial` awaits them in order until one bails, * `bail` stops on the first synchronous bail value, and `waterfall` composes * listeners around a final `next` callback. */type DispatchMode = 'emit' | 'parallel' | 'serial' | 'bail' | 'waterfall'