You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,16 +56,18 @@ You can subscribe a vue instance to a single standard channel if needed and defi
56
56
var vm =newVue({
57
57
channel:'blog',
58
58
echo: {
59
-
'BlogPostCreated':payload=> {
59
+
'BlogPostCreated':(payload, vm)=> {
60
60
console.log('blog post created', payload);
61
61
},
62
-
'BlogPostDeleted':payload=> {
62
+
'BlogPostDeleted':(payload, vm)=> {
63
63
console.log('blog post deleted', payload);
64
64
}
65
65
}
66
66
});
67
67
```
68
68
69
+
Since the scope of `this` would be the same as the scope where you declare your Vue instance a second parameter is added to these locally registered events. This parameter is a direct reference to your Vue instance, you can make any changes you need through there.
70
+
69
71
#### Subscribing to channels
70
72
71
73
Laravel Echo allows you to subscribe to: normal, private and presence channels.
@@ -79,10 +81,10 @@ If you would like to subscribe to a private channel instead, prefix your channel
79
81
var vm =newVue({
80
82
channel:'private:team.1',
81
83
echo: {
82
-
'BlogPostCreated':payload=> {
84
+
'BlogPostCreated':(payload, vm)=> {
83
85
console.log('blog post created', payload);
84
86
},
85
-
'BlogPostDeleted':payload=> {
87
+
'BlogPostDeleted':(payload, vm)=> {
86
88
console.log('blog post deleted', payload);
87
89
}
88
90
}
@@ -97,7 +99,7 @@ If you would like to subscribe to presence channel instead, prefix your channel
97
99
var vm =newVue({
98
100
channel:'presence:team.1.chat',
99
101
echo: {
100
-
'NewMessage':payload=> {
102
+
'NewMessage':(payload, vm)=> {
101
103
console.log('new message from team', payload);
102
104
}
103
105
}
@@ -112,10 +114,10 @@ If there's a scenario where you want to listen to events after certain condition
0 commit comments