/
index.d.ts
55 lines (47 loc) · 1.28 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Author: Meng
* Date: 2022-03-09
* Desc: 事件订阅分发
*/
interface Event {
key: string; // 事件名
callback: (data: any) => boolean | null; // 事件回调函数
tag: string; // 事件标识
type?: number; // 事件类型-1单次2普通
}
interface EventDao {
key: string; // 事件名
callback: (data: any) => boolean | null; // 事件回调函数
tag: string; // 事件标识
type: number; // 事件类型-1单次2普通
}
interface MsgDao {
key: string; // 事件名
data: any; // 数据
}
declare class EventBus {
private static _event_list: Array<EventDao>;
private static _msg_list: Array<MsgDao>;
/**
* 事件注册
* @param options {key: string, tag: string, type: number, callback}
*/
public static add(options: Event): void;
/**
* 订阅单次事件
* @param options {key: string, tag: string, callback}
*/
public static once(options: Event): void;
// 发送粘性消息
public static stick(key: string, data: any): void;
// 发送消息
public static send(key: string, data: any, delay: number): void;
/**
* 移除消息
* @param options {key: string, tag: string, callback}
*/
public static remove(options: Event): void;
// 清除全部消息
public static clear(): void;
}
export { EventBus };