From 63235b346c7b7aeee192d7547270a317e3ff2f08 Mon Sep 17 00:00:00 2001 From: Metin Seylan Date: Sun, 18 Nov 2018 15:08:41 +0300 Subject: [PATCH] component level usage added --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9790c85..51e7b09 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,10 @@ Vue.use(new VueSocketIO({ })) new Vue({ - router, - store, - render: h => h(App) -}).$mount('#app'); + router, + store, + render: h => h(App) +}).$mount('#app') ``` **Parameters**|**Type's**|**Default**|**Required**|**Description** @@ -53,4 +53,25 @@ debug|Boolean|`false`|Optional|Enable logging for debug connection|String/Socket.io-client|`null`|Required|Websocket server url or socket.io-client instance vuex.store|Vuex|`null`|Optional|Vuex store instance vuex.actionPrefix|String|`null`|Optional|Prefix for emitting server side vuex actions -vuex.mutationPrefix|String |`null`|Optional|Prefix for emitting server side vuex mutations \ No newline at end of file +vuex.mutationPrefix|String |`null`|Optional|Prefix for emitting server side vuex mutations + +#### 🌈 Component Level Usage + +``` javascript +new Vue({ + sockets: { + connect: function () { + console.log('socket connected') + }, + customEmit: function (data) { + console.log('this method was fired by the socket server. eg: io.emit("customEmit", data)') + } + }, + methods: { + clickButton: function (val) { + // $socket is socket.io-client instance + this.$socket.emit('emit_method', val); + } + } +}) +``` \ No newline at end of file