From 0359c5dd5922b3cd7c4d52f9221ca4fd4e4347dc Mon Sep 17 00:00:00 2001 From: IFA Date: Fri, 4 Sep 2020 10:58:53 +0200 Subject: [PATCH] Update README.md for making things clear (#277) --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 7b08e53..a37d8ea 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,35 @@ this.sockets.subscribe('EVENT_NAME', (data) => { this.sockets.unsubscribe('EVENT_NAME'); ``` +##### Defining handlers for events with special characters + +

If you want to handle 'kebab-case', or "event with space inside it" events, then you have to define it via the following way

+ +``` javascript +export default { + name: 'Test', + sockets: { + connect: function () { + console.log('socket to notification channel connected') + }, + }, + + data () { + return { + something: [ + // ... something here for the data if you need. + ] + } + }, + + mounted () { + this.$socket.subscribe("kebab-case", function(data) { + console.log("This event was fired by eg. sio.emit('kebab-case')", data) + }) + } +} +``` + #### 🏆 Vuex Integration

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`