airfone-client-js
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -31,5 +31,5 @@ export declare type StatusEvent = 'connect' | 'disconnect' | 'online' | 'offline' | 'error'; | ||
broadcast(payload: any): void; | ||
on(event: StatusEvent | MessageEvent | String, handle?: (payload: Payload) => void): AirfoneClient; | ||
on(events: StatusEvent | MessageEvent | String | Array<StatusEvent | MessageEvent | String>, handle?: (payload: Payload) => void): AirfoneClient; | ||
} | ||
export declare function getClient(options: ClientOptions): AirfoneClient; | ||
export {}; |
@@ -109,13 +109,19 @@ import { io } from 'socket.io-client'; | ||
} | ||
on(event, handle = (payload) => { }) { | ||
on(events, handle = (payload) => { }) { | ||
if (this.state != 0) { | ||
throw new Error('监听必须在调用connect方法之前添加'); | ||
} | ||
try { | ||
// @ts-ignore | ||
this.events.set(event, handle); | ||
let array = []; | ||
if (!Array.isArray(events)) { | ||
array.push(events); | ||
} | ||
catch (e) { | ||
this.listeners.set(event, handle); | ||
} | ||
array.forEach(event => { | ||
try { | ||
// @ts-ignore | ||
this.events.set(event, handle); | ||
} | ||
catch (e) { | ||
this.listeners.set(event, handle); | ||
} | ||
}); | ||
return this; | ||
@@ -122,0 +128,0 @@ } |
{ | ||
"name": "airfone-client-js", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6982
165