UNPKG

@boost/event

Version:

An event system with multiple emitter patterns.

18 lines (17 loc) 626 B
import { BaseEvent } from './BaseEvent.mjs'; import { debug } from './debug.mjs'; class BailEvent extends BaseEvent { /** * Synchronously execute listeners with the defined arguments. * If a listener returns `false`, the loop with be aborted early, * and the emitter will return `true` (for bailed). */ emit(args, scope) { if (process.env.NODE_ENV !== "production") { debug('Emitting "%s%s" as bail', this.name, scope ? `:${scope}` : ''); } return [...this.getListeners(scope)].some(listener => listener(...args) === false); } } export { BailEvent }; //# sourceMappingURL=BailEvent.mjs.map