Skip to content

Commit 0359c5d

Browse files
authored
Update README.md for making things clear (#277)
1 parent d7ddfb2 commit 0359c5d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,35 @@ this.sockets.subscribe('EVENT_NAME', (data) => {
123123
this.sockets.unsubscribe('EVENT_NAME');
124124
```
125125

126+
##### Defining handlers for events with special characters
127+
128+
<p>If you want to handle 'kebab-case', or "event with space inside it" events, then you have to define it via the following way</p>
129+
130+
``` javascript
131+
export default {
132+
name: 'Test',
133+
sockets: {
134+
connect: function () {
135+
console.log('socket to notification channel connected')
136+
},
137+
},
138+
139+
data () {
140+
return {
141+
something: [
142+
// ... something here for the data if you need.
143+
]
144+
}
145+
},
146+
147+
mounted () {
148+
this.$socket.subscribe("kebab-case", function(data) {
149+
console.log("This event was fired by eg. sio.emit('kebab-case')", data)
150+
})
151+
}
152+
}
153+
```
154+
126155
#### 🏆 Vuex Integration
127156
<p>When you set store parameter in installation, `Vue-Socket.io` will start sending events to Vuex store. If you set both prefix for vuex, you can use `actions` and `mutations` at the same time. But, best way to use is just `actions`</p>
128157

0 commit comments

Comments
 (0)