mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Fix: warning for beforeUnmount hook for vue 3
This commit is contained in:
parent
3337d43298
commit
a062b3f46f
2 changed files with 6 additions and 5 deletions
|
@ -28,17 +28,18 @@ export default class VueSocketIO {
|
||||||
*/
|
*/
|
||||||
install(Vue){
|
install(Vue){
|
||||||
|
|
||||||
const version = Number(Vue.version.split('.')[0])
|
const version = Number(Vue.version.split('.')[0]);
|
||||||
|
|
||||||
if (version >= 3) {
|
if (version >= 3) {
|
||||||
Vue.config.globalProperties.$socket = this.io;
|
Vue.config.globalProperties.$socket = this.io;
|
||||||
Vue.config.globalProperties.$vueSocketIo = this;
|
Vue.config.globalProperties.$vueSocketIo = this;
|
||||||
|
Vue.mixin(Mixin(true));
|
||||||
} else {
|
} else {
|
||||||
Vue.prototype.$socket = this.io;
|
Vue.prototype.$socket = this.io;
|
||||||
Vue.prototype.$vueSocketIo = this;
|
Vue.prototype.$vueSocketIo = this;
|
||||||
|
Vue.mixin(Mixin(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.mixin(Mixin);
|
|
||||||
|
|
||||||
Logger.info('Vue-Socket.io plugin enabled');
|
Logger.info('Vue-Socket.io plugin enabled');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default {
|
export default (isVue3) => ({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign runtime callbacks
|
* Assign runtime callbacks
|
||||||
|
@ -39,7 +39,7 @@ export default {
|
||||||
/**
|
/**
|
||||||
* unsubscribe when component unmounting
|
* unsubscribe when component unmounting
|
||||||
*/
|
*/
|
||||||
beforeDestroy(){
|
[isVue3 ? 'beforeUnmount' : 'beforeDestroy'](){
|
||||||
|
|
||||||
if(this.$options.sockets){
|
if(this.$options.sockets){
|
||||||
|
|
||||||
|
@ -53,4 +53,4 @@ export default {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
});
|
Loading…
Add table
Reference in a new issue