Vue-Socket.io 0,1

socket.io implemantation for vuejs

3 years after

Vue-Socket.io

socket.io implemantation for vuejs

Install

  npm install vue-socket.io --save

or

  bower install vue-socket.io

Usage

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);
    }
  }
})

Example

Realtime Car Tracker System

Simple Chat App

License

WTFPL

Related Repositories

awesome-vue

awesome-vue

A curated list of awesome things related to Vue.js ...

awesome-github-vue

awesome-github-vue

Vue相关开源项目库汇总 ...

vue-websocket

vue-websocket

Simple websocket (socket.io) plugin for Vue.js ...

vue-syncers-feathers

vue-syncers-feathers

Synchronises feathers services with vue objects, updated in real time ...

vue-feathers

vue-feathers

Integration with the Feathers framework for Vue.js ...


Top Contributors

MetinSeylan