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 {
socket: any
listeners: any
socket: Socket | null
listeners: { event: any; callback: any }[]
constructor() {
this.socket = null
this.listeners = []
@@ -40,7 +40,7 @@ class SocketWrapper {
bindListeners() {
this.listeners.forEach(
({ event, callback }: { event: any; callback: any }) => {
this.socket.on(event, callback)
if (this.socket !== null) this.socket.on(event, callback)
}
)
}