Metin Seylan 6 years ago
parent 4b7c282d0c
commit 176c060356

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
{
"name": "vue-socket.io",
"author": "Metin Seylan <metinsyln@gmail.com>",
"version": "3.0.3",
"version": "3.0.4",
"description": "socket.io implemantation for vuejs and vuex",
"main": "dist/vue-socketio.js",
"scripts": {

@ -1,9 +1,26 @@
export default {
/**
* lets collect all socket callback functions then register
* Assign runtime callbacks
*/
created(){
beforeCreate(){
if(!this.sockets) this.sockets = {};
this.sockets.subscribe = (event, callback) => {
this.$vueSocketIo.emitter.addListener(event, callback, this);
};
this.sockets.unsubscribe = (event) => {
this.$vueSocketIo.emitter.removeListener(event, this);
};
},
/**
* Register all socket events
*/
mounted(){
if(this.$options.sockets){
@ -15,19 +32,6 @@ export default {
});
this.sockets = {
subscribe: (event, callback) => {
this.$vueSocketIo.emitter.addListener(event, callback, this);
},
unsubscribe: (event) => {
this.$vueSocketIo.emitter.removeListener(event, this);
}
};
}
},

Loading…
Cancel
Save