Create README.md

pull/15/head
Metin Seylan 9 years ago
parent e3b6da9d6e
commit bfdac9ab09

@ -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);
}
}
})
```
Loading…
Cancel
Save