From c5a68891766dd7766d93c5038e86c47b6045943c Mon Sep 17 00:00:00 2001 From: Metin Seylan Date: Sun, 18 Nov 2018 17:15:14 +0300 Subject: [PATCH] added dynamic listenler docs --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 05959da..61310fd 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,20 @@ new Vue({ methods: { clickButton: function (data) { // $socket is socket.io-client instance - this.$socket.emit('emit_method', data); + this.$socket.emit('emit_method', data) } } }) +``` + +##### Dynamic Listenlers + +

if you need consuming events dynamically in runtime, you can use `subscribe` and `unsubscribe` methods in Vue component

+ +``` javascript +this.sockets.subscribe('EVENT_NAME', (data) => { + this.msg = data.message; +}); + +this.sockets.unsubscribe('EVENT_NAME'); ``` \ No newline at end of file