mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
added dynamic listenler docs
This commit is contained in:
parent
b59f1a4a60
commit
c5a6889176
1 changed files with 13 additions and 1 deletions
14
README.md
14
README.md
|
@ -72,8 +72,20 @@ new Vue({
|
||||||
methods: {
|
methods: {
|
||||||
clickButton: function (data) {
|
clickButton: function (data) {
|
||||||
// $socket is socket.io-client instance
|
// $socket is socket.io-client instance
|
||||||
this.$socket.emit('emit_method', data);
|
this.$socket.emit('emit_method', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Dynamic Listenlers
|
||||||
|
|
||||||
|
<p>if you need consuming events dynamically in runtime, you can use `subscribe` and `unsubscribe` methods in Vue component</p>
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
this.sockets.subscribe('EVENT_NAME', (data) => {
|
||||||
|
this.msg = data.message;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sockets.unsubscribe('EVENT_NAME');
|
||||||
|
```
|
Loading…
Add table
Reference in a new issue