Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 6520e25

Browse files
author
Kerstens Maxim
authored
Merge pull request happyDemon#21 from masterix21/master
Fixed unsubscribe and re-subscribe bug
2 parents 4771db4 + d08b6bd commit 6520e25

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

dist/build.js

+1-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/build.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vue-echo.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
}
2121

2222
Vue.mixin({
23-
created(){
23+
mounted() {
2424
let channel = this.$options['channel'];
2525

2626
if(channel)
@@ -46,16 +46,27 @@ export default {
4646
// Bind the VM as second parameter
4747
this.channel.listen(key, (payload) => {
4848
events[key](payload, this);
49-
});
49+
});
5050
}, this);
5151
}
5252
}
5353
},
5454
beforeDestroy(){
55-
if(this.$options['channel']){
56-
this.channel.unsubscribe();
55+
let channel = this.$options['channel'];
56+
57+
if(channel){
58+
if(channel.startsWith('private:'))
59+
{
60+
channel = channel.replace('private:', '');
61+
}
62+
else if(channel.startsWith('presence:'))
63+
{
64+
channel = channel.replace('presence:', '');
65+
}
66+
67+
this.$echo.leave(channel);
5768
}
5869
}
5970
})
6071
}
61-
}
72+
}

0 commit comments

Comments
 (0)