From 4fba4071f7593f3cbe34d728bd2def1ec4a97021 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mehmet=20Y=C4=B1lmaz?=
Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements
+
Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements.
###### Demo
- Chat Application
From 45860773e4edfc7f366a88f584e5c460738ddce0 Mon Sep 17 00:00:00 2001
From: dailing <1432559604@qq.com>
Date: Mon, 16 Mar 2020 22:19:25 +0800
Subject: [PATCH 2/9] Update README.md (#241)
It seems that `import SocketIO from "socket.io-client"` is missing from the examples.
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 803cb6c..968852a 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ import Vue from 'vue'
import store from './store'
import App from './App.vue'
import VueSocketIO from 'vue-socket.io'
+import SocketIO from "socket.io-client"
Vue.use(new VueSocketIO({
debug: true,
@@ -58,6 +59,7 @@ import Vue from 'vue'
import store from './store'
import App from './App.vue'
import VueSocketIO from 'vue-socket.io'
+import SocketIO from "socket.io-client"
const options = { path: '/my-app/' }; //Options object to pass into SocketIO
From 3d04f310a3e7b6912c43b8cd29732433fb008e57 Mon Sep 17 00:00:00 2001
From: Metin Seylan
Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements.
+
Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements
###### Demo - Chat Application @@ -33,7 +33,6 @@ import Vue from 'vue' import store from './store' import App from './App.vue' import VueSocketIO from 'vue-socket.io' -import SocketIO from "socket.io-client" Vue.use(new VueSocketIO({ debug: true, @@ -59,7 +58,6 @@ import Vue from 'vue' import store from './store' import App from './App.vue' import VueSocketIO from 'vue-socket.io' -import SocketIO from "socket.io-client" const options = { path: '/my-app/' }; //Options object to pass into SocketIO @@ -88,7 +86,6 @@ connection|String/Socket.io-client|`null`|Required|Websocket server url or socke 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 -vuex.options.useConnectionNamespace |Boolean|`false`|Optional|Use more than one connection namespace #### 🌈 Component Level Usage @@ -149,41 +146,6 @@ export default new Vuex.Store({ }) ``` -#### 🏆 Connection Namespace -
When you need to handle more than one namespaced connection, you need to set the `useConnectionNamespace` property of -the options object to true. What this does is telling the plugin that you are going to be using more than one namespaced connection and you want to put every connection in their own `$socket` key.
- -``` javascript -import Vue from 'vue' -import store from './store' -import App from './App.vue' -import VueSocketIO from 'vue-socket.io' - -Vue.use(new VueSocketIO({ - debug: true, - connection: 'http://metinseylan.com:1992/mynamespace', - vuex: { - store, - options: { - useConnectionNamespace: true - } - }, - options: { path: "/my-app/" } //Optional options -})) - -new Vue({ - router, - store, - render: h => h(App) -}).$mount('#app') -``` - -Then use it like this: - -``` javascript -Vue.$socket.mynamespace.emit('emit_method', data) -``` - ## Stargazers over time [![Stargazers over time](https://starcharts.herokuapp.com/MetinSeylan/Vue-Socket.io.svg)](https://starcharts.herokuapp.com/MetinSeylan/Vue-Socket.io) diff --git a/dist/vue-socketio.js b/dist/vue-socketio.js index 595a9ef..504c329 100644 --- a/dist/vue-socketio.js +++ b/dist/vue-socketio.js @@ -5,6 +5,6 @@ * @author Feross AboukhadijehIf you want to handle 'kebab-case', or "event with space inside it" events, then you have to define it via the following way
+ +``` javascript +export default { + name: 'Test', + sockets: { + connect: function () { + console.log('socket to notification channel connected') + }, + }, + + data () { + return { + something: [ + // ... something here for the data if you need. + ] + } + }, + + mounted () { + this.$socket.subscribe("kebab-case", function(data) { + console.log("This event was fired by eg. sio.emit('kebab-case')", data) + }) + } +} +``` + #### 🏆 Vuex IntegrationWhen you set store parameter in installation, `Vue-Socket.io` will start sending events to Vuex store. If you set both prefix for vuex, you can use `actions` and `mutations` at the same time. But, best way to use is just `actions`
From c555cc72ef3e49f86cd92da67dee9f9e22716ffc Mon Sep 17 00:00:00 2001 From: Metin Seylan+ + + +
Vue-Socket.io is a socket.io integration for Vuejs, easy to use, supporting Vuex and component level socket consumer managements
###### Demo