var app = new Vue({ el: '#app', data() { return { url: config.baseUrl + '/Home/BuildingData', model: null, events: ['OrganEntityInserted', 'OrganEntityUpdated', 'OrganEntityDeleted', 'BuildingEntityInserted', 'BuildingEntityUpdated', 'BuildingEntityDeleted'] }; }, mounted: function () { app = this; this.subscribe(); this.load(); }, beforeDestroy: function () { PubSub.unsubscribes(this.events); }, methods: { subscribe: function () { PubSub.subscribes(this.events, function (method, data) { app.load(); }); }, load: function () { axios.post(this.url).then(function (response) { app.model = response.data; }); } } });