E
E
ezpy2017-07-16 20:28:28
Vue.js
ezpy, 2017-07-16 20:28:28

How to properly connect vuex with websocket?

Hello, could someone explain how to properly work with websocket through vuex.
Any information would be helpful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yeldos Adetbekov, 2017-07-16
@ezpy

My server has not made friends with socket.io, but they say it is already a proven tool (Node.js is ideal). And I used the native and most common js waebsocket. When mounted() initialized $store.state.ws through actions in vuex(this.$store.dispatch('setWS', 'ws://blahblah/')) and then used the usual websocket getters. Through .send('') sent, and through .onmessage(data){} received data. I hung a watcher on getters and voila) Honestly, it's a hemorrhoid if used in large volumes, and if you need private solutions, then it's very ok)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question