sorribas/typesafe-event-emitter

Doesn't work for event with empty callback

Opened this issue · 0 comments

The following doesn't work.

type Events = {
    buttonClicked: void
}

function makeSomeEventEmitter() {
    const em: TypeSafeEventEmitter<Events> = new EventEmitter()

    em.emit("buttonClicked")

    return em;
}

// consumer
const someEventEmitter = makeSomeEventEmitter()

someEventEmitter.on('buttonClicked', () => {

})

We have to give a null value to the emit method, which seems bad for performance reasons.
It would be better to not have to send a value when the type is void, if it is possible.