-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to catch all events? #230
Comments
just a thought, maybe regex fits better in this case than wildcards :) |
Here's a pretty hacky way to do it (if you take a look at var oldEmit = this.compiler.emitter.emit
this.compiler.emitter.emit = function () {
console.log('got event: ' + arguments[0])
oldEmit.apply(this, arguments)
} Introducing wildcards/regex into the emitter implementation would bring about performance concerns, since the emitter is very central in the observation implementation and |
Thanks, this kind of hacky solution is good enough for me 😄 |
For those looking to do the same thing with version 1.0+, the syntax is like this: const old_on = this.$on;
this.$on = (...args) => {
// custom logic here like pushing to a callback array or something
old_on.apply(this, args);
}; |
example for version 2.* ? |
Did you try that code? Should still work :) |
@endoplasmic your solution can also work for 2.0 |
@njleonzhang ya, I edited my comment above to say |
@endoplasmic It's great and has no dependence to |
@njleonzhang any example for this ? it did not work at my side. |
@xiaolp endoplasmic has provided sample |
i very stress |
i add this code into beforeCreate but not work |
Is there a way to catch all click events |
Hi,
if there a possibility to use VM $on() method to catch all incoming events?
It would be even cooler to enable wildcards like:
to catch all events starting with 'delete-'
Right now such functionality is useful for me for diagnostics, but I think it would be useful in several other scenarios as well.
The text was updated successfully, but these errors were encountered: