Skip to content

Commit c5a6889

Browse files
committed
added dynamic listenler docs
1 parent b59f1a4 commit c5a6889

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,20 @@ new Vue({
7272
methods: {
7373
clickButton: function (data) {
7474
// $socket is socket.io-client instance
75-
this.$socket.emit('emit_method', data);
75+
this.$socket.emit('emit_method', data)
7676
}
7777
}
7878
})
79+
```
80+
81+
##### Dynamic Listenlers
82+
83+
<p>if you need consuming events dynamically in runtime, you can use `subscribe` and `unsubscribe` methods in Vue component</p>
84+
85+
``` javascript
86+
this.sockets.subscribe('EVENT_NAME', (data) => {
87+
this.msg = data.message;
88+
});
89+
90+
this.sockets.unsubscribe('EVENT_NAME');
7991
```

0 commit comments

Comments
 (0)