Created
March 4, 2018 22:53
-
-
Save jeffochoa/efb9c01ca9d1715a4618a095e292ba1c to your computer and use it in GitHub Desktop.
Vue event dispatcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event { | |
constructor() { | |
this.vue = new Vue(); | |
} | |
fire(event, data = null) { | |
this.vue.$emit(event, data); | |
} | |
listen(event, callback) { | |
this.vue.$on(event, callback); | |
} | |
} | |
module.exports = Event; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment