My emitter:
import Emittery from 'emittery'
import { logger } from './'
const eventBus: Emittery = new Emittery({
debug: {
name: 'eventBus',
enabled: process.env.ENVIRONMENT !== 'production',
logger: (type, debugName, eventName, eventData) => {
logger.debug(`${debugName}: ${type} ${JSON.stringify(eventName)}`, eventData)
}
}
})
export default eventBus
My handler
eventBus.on('closeMailer', () => {
logger.debug('Closing mailer')
mailer.close()
})
My event
eventBus.emit('closeMailer')
The result:
[1630369974586] DEBUG (20026 on selfagency-m1mini.local): eventBus: subscribe "closeMailer"
[1630369974587] DEBUG (20026 on selfagency-m1mini.local): eventBus: emit undefined
When I try to use a Symbol
instead of a string
, as specified in the README
, TypeScript says it's an invalid type for the parameter.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too