const GlobalEvent = require('./event');
window.Event = new GlobalEvent();
Then you can listen for events from other Vue components
export default {
methods: {
myHandler() {
alert('Do something');
}
},
created() {
Event.listen('myEvent', (data) => this.myHandler(data));
}
}
Also you can fire those events from anywhere
Event.fire('myEvent', {foo: "bar"});
This was taken from laracasts: Component Communication Example #2: Event Dispatcher
Hi @jeffochoa. Thank you for a gist. Where should I paste
const GlobalEvent = require('./event');
?