Open
Description
What problem does this feature solve?
Currently, if an event is registered via vm.$on('event-name', handler)
, it does not appear in the this.$listeners
object (Vue 2.6.x)
In some instances you only want to handle the event processing if there is indeed a listener registered (for performance reasons). But when component event listeners are registered programatically via this.$on
(or vmReference.$on
) it is not currently possible to see them in this.$listeners
, e.g.:
if (this.$listeners['event-name']) {
// Do something computationally intensive
// then emit event
this.$emit('event-name', resultOfComputation)
}
What does the proposed API look like?
No new API for the public.