From 0b27e5218b6663913921e438da925411043df84a Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 16 May 2017 23:08:54 -0700 Subject: [PATCH] readme updates --- README.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8d76d8c..05efb3d 100755 --- a/README.md +++ b/README.md @@ -35,18 +35,12 @@ Vue.use(VueNativeSock, 'ws://localhost:9090', store, {format: 'json'}) #### On Vuejs instance usage ``` js var vm = new Vue({ - sockets:{ - connect: function(){ - console.log('socket connected') - }, - customEmit: function(val){ - 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); + clickButton: function(val) { + // $socket is [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) instance + this.$socket.send('some data') + // or with {format: 'json'} enabled + this.$socket.sendObj({awesome: 'data'}) } } }) @@ -55,13 +49,11 @@ var vm = new Vue({ #### Dynamic socket event listeners Create a new listener ``` js -this.$options.sockets.event_name = (data) => { - console.log(data) -} +this.$options.sockets.event_name = (data) => console.log(data) ``` Remove existing listener ``` js -delete this.$options.sockets.event_name; +delete this.$options.sockets.event_name ``` #### Vuex Store integration