From 14320669ebc4c9224cdfb14bef25470e24b372cc Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 17 Apr 2018 22:05:07 -0400 Subject: [PATCH] s8e114 centralizing the bus --- section-code/src/components/UserEdit.vue | 3 ++- section-code/src/main.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/section-code/src/components/UserEdit.vue b/section-code/src/components/UserEdit.vue index f2defed..028b325 100644 --- a/section-code/src/components/UserEdit.vue +++ b/section-code/src/components/UserEdit.vue @@ -13,7 +13,8 @@ methods: { editAge(){ this.userAge = 30; - eventBus.$emit('ageWasEdited', this.userAge) + // eventBus.$emit('ageWasEdited', this.userAge) + eventBus.changeAge(this.userAge); } } } diff --git a/section-code/src/main.js b/section-code/src/main.js index e6e6ea3..565f120 100644 --- a/section-code/src/main.js +++ b/section-code/src/main.js @@ -1,7 +1,13 @@ import Vue from 'vue' import App from './App.vue' -export const eventBus = new Vue(); +export const eventBus = new Vue({ + methods:{ + changeAge(age){ + this.$emit('ageWasEdited', age) + } + } +}); new Vue({ el: '#app',