refactor: CustomWebsocket

This commit is contained in:
Roberto Tonino 2021-03-01 21:25:59 +01:00
parent cbf3a5c677
commit efefa7bbf7
2 changed files with 9 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,3 @@
import store from '@/store'
let wasEventListenerAdded = false
class CustomSocket extends WebSocket {
@ -8,7 +6,8 @@ class CustomSocket extends WebSocket {
}
emit(key, data) {
if (this.readyState !== WebSocket.OPEN) return false
this.send(JSON.stringify({ key: key, data: data }))
this.send(JSON.stringify({ key, data }))
}
on(key, cb) {
if (!wasEventListenerAdded) {