question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a way to check if a component responds to an event, or make vm._events public

See original GitHub issue

What 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:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ChristianKienlecommented, Nov 17, 2018

@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 😃

2reactions
ChristianKienlecommented, Nov 16, 2018

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. 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monitor virtual machines changes with Azure Event Grid
Check for changes in virtual machines (VMs) by using Azure Event Grid and Azure Logic Apps.
Read more >
VM Component Protection - VMware Docs
Go to the Configure tab and click vSphere Availability and Edit. Under Failures and Responses you can select Datastore with PDL or Datastore ......
Read more >
How to Write Window Listeners - Oracle Help Center
To implement a window-closing handler, use the setDefaultCloseOperation(WindowConstants. DO_NOTHING_ON_CLOSE) method to enable the window listener to provide ...
Read more >
Detect click outside element - Stack Overflow
Add tabindex attribute to your component so that it can be focused and do the ... Vue.directive('click-outside', { bind () { this.event =...
Read more >
How To Handle DOM and Window Events with React
Throughout the tutorial, you'll learn how to add event handlers to ... This component will accept input and validate it, or make sure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found