File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export default {
20
20
}
21
21
22
22
Vue . mixin ( {
23
- created ( ) {
23
+ mounted ( ) {
24
24
let channel = this . $options [ 'channel' ] ;
25
25
26
26
if ( channel )
@@ -46,16 +46,27 @@ export default {
46
46
// Bind the VM as second parameter
47
47
this . channel . listen ( key , ( payload ) => {
48
48
events [ key ] ( payload , this ) ;
49
- } ) ;
49
+ } ) ;
50
50
} , this ) ;
51
51
}
52
52
}
53
53
} ,
54
54
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 ) ;
57
68
}
58
69
}
59
70
} )
60
71
}
61
- }
72
+ }
You can’t perform that action at this time.
0 commit comments