我想向用户显示 socket.io 连接的状态。为此,我有一堆这些要告诉用户。
#I can't use `*` because I have some customized events
socket.on 'my_command', =>
set_status "connecting"
socket.on 'connecting', =>
set_status "connecting"
socket.on 'disconnect', =>
set_status "disconnect"
socket.on 'connect_failed', =>
set_status "connect_failed"
有没有办法将所有这些压缩成更小的东西?就像是:
socket.on 'connecting, disconnect, connect_failed', (name_of_event)=>
set_status name_of_event