From bfdac9ab09fcaaadf09920ac586c5d0cf7b917a9 Mon Sep 17 00:00:00 2001 From: Metin Seylan Date: Mon, 9 May 2016 23:41:17 +0300 Subject: [PATCH] Create README.md --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a93968c --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Vue-Socket.io +socket.io implemantation for vuejs + +## Install + + ``` bash + npm install vue-socket.io --save + ``` + or + + ``` bash + bower install vue-socket.io + ``` + +## Usage + +``` js +import VueSocketio from 'vue-socket.io'; // for ES6 + +// var VueSocketio require('vue-socket.io') // for commonjs + +Vue.use(VueSocketio, 'http://socketserver.com:1923'); // Automaticly socket connect from url string + +/* + import socketio from 'socket.io-client'; + + var ioInstance socketio('http://socketserver.com:1923'); + + Vue.use(VueSocketio, ioInstance); // bind custom socketio instance +*/ + +var vm = new Vue({ + sockets:{ + connect: function(){ + console.log('socket connected') + }, + customEmit: function(){ + console.log('this method fired by socket server. eg: io.emit("customEmit", data)') + } + }, + methods: { + clickButton: function(val){ + // $socket is socket.io-client instance + this.$socket.emit('emit_method', val); + } + } +}) +```