Last active
February 2, 2017 11:53
-
-
Save andreipfeiffer/a3837b5bcdd80c2a8707dc48b52819fb to your computer and use it in GitHub Desktop.
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
// global Event Bus | |
const eventBus = new Vue(); | |
/* ... */ | |
// some deeply nested component | |
methods: { | |
onClick() { | |
// emit a custom event on the Event Bus, not on "this" component | |
eventBus.$emit('save'); | |
} | |
} | |
/* ... */ | |
// any other component | |
mounted() { | |
// subscribe to event on the Event Bus | |
eventBus.$on('save', () => {/**/}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment