This commit is contained in:
Chen, Tai-Lin committed 2024-03-25 15:48:37 +08:00
1 parent 59a0865157
commit 7f33100132
1 file changed
+4 -4
+4 -4
View File
@@ -1,8 +1,8 @@
import io from 'socket.io-client' import { io, Socket } from 'socket.io-client'
class SocketWrapper { class SocketWrapper {
socket: any socket: Socket | null
listeners: any listeners: { event: any; callback: any }[]
constructor() { constructor() {
this.socket = null this.socket = null
this.listeners = [] this.listeners = []
@@ -40,7 +40,7 @@ class SocketWrapper {
bindListeners() { bindListeners() {
this.listeners.forEach( this.listeners.forEach(
({ event, callback }: { event: any; callback: any }) => { ({ event, callback }: { event: any; callback: any }) => {
this.socket.on(event, callback) if (this.socket !== null) this.socket.on(event, callback)
} }
) )
} }