Fix: warning for beforeUnmount hook for vue 3

pull/306/head
Sebastien Hernoux 4 years ago
parent 3337d43298
commit a062b3f46f

@ -28,17 +28,18 @@ export default class VueSocketIO {
*/
install(Vue){
const version = Number(Vue.version.split('.')[0])
const version = Number(Vue.version.split('.')[0]);
if (version >= 3) {
Vue.config.globalProperties.$socket = this.io;
Vue.config.globalProperties.$vueSocketIo = this;
Vue.mixin(Mixin(true));
} else {
Vue.prototype.$socket = this.io;
Vue.prototype.$vueSocketIo = this;
Vue.mixin(Mixin(false));
}
Vue.mixin(Mixin);
Logger.info('Vue-Socket.io plugin enabled');

@ -1,4 +1,4 @@
export default {
export default (isVue3) => ({
/**
* Assign runtime callbacks
@ -39,7 +39,7 @@ export default {
/**
* unsubscribe when component unmounting
*/
beforeDestroy(){
[isVue3 ? 'beforeUnmount' : 'beforeDestroy'](){
if(this.$options.sockets){
@ -53,4 +53,4 @@ export default {
}
}
});
Loading…
Cancel
Save