Add a way to check if a component responds to an event, or make vm._events public
See original GitHub issueWhat problem does this feature solve?
It would be nice to be able to check if a component responds to a given event or not. We can already do so for listeners declared in the template through the vm.$listeners
object, but the ones registered with vm.$on()
/ vm.$off()
don’t show up in this object, they are stored in the private vm._events
object.
I would like to suggest to either add a function that checks if a component responds to a given event, or to make vm._events
public, and call it vm.$events
What does the proposed API look like?
A method called vm.$responds(event)
could be considered, returning true
if a component responds to a given event, false
otherwise. If an array of strings is passed to this method instead of a string, it could return true
if the component responds to some of these events.
Alternatively, the interface could simply be vm.$events
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:13 (5 by maintainers)
Top GitHub Comments
@lehni just saw that you are behind Paper.js. 😍
I regularly play with the Voronoi example because I noticed that it calms me down and helps me relax. If you are in the area ping me for a beer/coffee/whatever 😃
Just an idea: instead of emitting the costly object you could emit a function that, when called, returns the costly object. Then the costly object is only ever created when someone actually calls the function you emit which in turn should only happen when someone is listening to your event. Just my two cents. Not sure if this any good though. 😁