airfone-client-js
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -22,2 +22,3 @@ export declare type StatusEvent = 'connect' | 'disconnect' | 'online' | 'offline' | 'error'; | ||
} | ||
export declare type Handle = (payload: Payload) => {}; | ||
export default class AirfoneClient { | ||
@@ -32,10 +33,20 @@ readonly options: ClientOptions; | ||
disconnect(): void; | ||
chat(id: String, payload: any, receive?: Function): void; | ||
chat(id: String, payload: any, receive?: Handle): void; | ||
notice(role: String, payload: any): void; | ||
broadcast(payload: any): void; | ||
broadcasts(payload: any): void; | ||
onIf(bool: boolean, events: StatusEvent | MessageEvent | String | Array<StatusEvent | MessageEvent | String>, handle?: (payload: Payload) => void): this; | ||
on(events: StatusEvent | MessageEvent | String | Array<StatusEvent | MessageEvent | String>, handle?: (payload: Payload) => void): this; | ||
onIf(bool: boolean, events: StatusEvent, handle: Handle): this; | ||
onIf(bool: boolean, events: MessageEvent, handle: Handle): this; | ||
onIf(bool: boolean, events: String, handle: Handle): this; | ||
onIf(bool: boolean, events: Array<StatusEvent>, handle: Handle): this; | ||
onIf(bool: boolean, events: Array<MessageEvent>, handle: Handle): this; | ||
onIf(bool: boolean, events: Array<String>, handle: Handle): this; | ||
on(events: StatusEvent, handle: Handle): this; | ||
on(events: MessageEvent, handle: Handle): this; | ||
on(events: String, handle: Handle): this; | ||
on(events: Array<StatusEvent>, handle: Handle): this; | ||
on(events: Array<MessageEvent>, handle: Handle): this; | ||
on(events: Array<String>, handle: Handle): this; | ||
} | ||
export declare function getClient(options: ClientOptions): AirfoneClient; | ||
export {}; |
@@ -144,4 +144,5 @@ import { io } from 'socket.io-client'; | ||
} | ||
onIf(bool, events, handle = (payload) => { }) { | ||
onIf(bool, events, handle) { | ||
if (bool) { | ||
// @ts-ignore | ||
return this.on(events, handle); | ||
@@ -151,3 +152,3 @@ } | ||
} | ||
on(events, handle = (payload) => { }) { | ||
on(events, handle) { | ||
if (this.state != 0) { | ||
@@ -154,0 +155,0 @@ throw new Error('监听必须在调用connect方法之前添加'); |
{ | ||
"name": "airfone-client-js", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"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
9551
226