fastevent 1.0.4 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.js +20 -0
- package/.vscode/settings.json +18 -0
- package/CHANGELOG.md +22 -6
- package/dist/devTools.d.mts +308 -0
- package/dist/devTools.d.ts +308 -0
- package/dist/devTools.js +3 -0
- package/dist/devTools.js.map +1 -0
- package/dist/devTools.mjs +3 -0
- package/dist/devTools.mjs.map +1 -0
- package/dist/index.d.mts +40 -17
- package/dist/index.d.ts +40 -17
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/example/README.md +54 -0
- package/example/eslint.config.js +28 -0
- package/example/index.html +13 -0
- package/example/package.json +29 -0
- package/example/pnpm-lock.yaml +2047 -0
- package/example/public/vite.svg +1 -0
- package/example/src/App.css +42 -0
- package/example/src/App.tsx +60 -0
- package/example/src/assets/react.svg +1 -0
- package/example/src/index.css +68 -0
- package/example/src/main.tsx +10 -0
- package/example/src/vite-env.d.ts +1 -0
- package/example/tsconfig.app.json +26 -0
- package/example/tsconfig.json +7 -0
- package/example/tsconfig.node.json +24 -0
- package/example/vite.config.ts +7 -0
- package/package.json +15 -2
- package/readme.md +275 -66
- package/readme_cn.md +275 -70
- package/src/__tests__/emit.test.ts +68 -69
- package/src/__tests__/emitAsync.test.ts +41 -42
- package/src/__tests__/many.test.ts +15 -16
- package/src/__tests__/meta.test.ts +19 -19
- package/src/__tests__/off.test.ts +162 -162
- package/src/__tests__/onany.test.ts +97 -98
- package/src/__tests__/once.test.ts +42 -43
- package/src/__tests__/retain.test.ts +36 -36
- package/src/__tests__/scope.test.ts +38 -39
- package/src/__tests__/types.test.ts +97 -80
- package/src/__tests__/waitFor.test.ts +36 -29
- package/src/__tests__/wildcard.test.ts +114 -115
- package/src/devTools.ts +166 -0
- package/src/event.ts +272 -222
- package/src/scope.ts +64 -55
- package/src/types.ts +38 -34
- package/src/utils/WeakObjectMap.ts +64 -0
- package/tsconfig.json +103 -111
- package/tsup.config.ts +17 -6
package/.prettierrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
// 每行末尾不添加分号
|
|
3
|
+
semi: true,
|
|
4
|
+
// 字符串使用单引号
|
|
5
|
+
singleQuote: true,
|
|
6
|
+
// tab缩进长度,默认为2
|
|
7
|
+
tabWidth: 4,
|
|
8
|
+
// 对象中打印空格
|
|
9
|
+
bracketSpacing: true,
|
|
10
|
+
// 文末自动添加空格等结尾
|
|
11
|
+
endOfLine: 'auto',
|
|
12
|
+
// 换行长度,默认80
|
|
13
|
+
printWidth: 180,
|
|
14
|
+
// 多行后面打印逗号
|
|
15
|
+
trailingComma: 'all',
|
|
16
|
+
// 箭头函数总是加小括号
|
|
17
|
+
arrowParens: 'always',
|
|
18
|
+
// 換行 保留??
|
|
19
|
+
proseWrap: 'preserve',
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"terminal.integrated.persistentSessionReviveProcess": "onExitAndWindowClose",
|
|
3
|
+
"files.exclude": {
|
|
4
|
+
"**/.git": true,
|
|
5
|
+
"**/.svn": true,
|
|
6
|
+
"**/.hg": true,
|
|
7
|
+
"**/CVS": true,
|
|
8
|
+
"**/.DS_Store": true,
|
|
9
|
+
"**/Thumbs.db": true,
|
|
10
|
+
"**/node_modules": false
|
|
11
|
+
},
|
|
12
|
+
"editor.tabSize": 4,
|
|
13
|
+
"editor.insertSpaces": true,
|
|
14
|
+
"editor.detectIndentation": false,
|
|
15
|
+
"editor.formatOnSave": true,
|
|
16
|
+
"prettier.tabWidth": 4,
|
|
17
|
+
"oxlint.enable": true
|
|
18
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,32 +1,48 @@
|
|
|
1
1
|
# fastevent
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c93387f: feat: 新增加了 fastevent/devtools 功能,可以导入在`Redux Dev Tools`查看事件,用于调试。
|
|
8
|
+
feat: 新增加了 debug 选项,用于调试时使用。
|
|
9
|
+
feat: 增加了 onExecuteListener 选项,在每次执行侦听器后执行,仅当 debug=true 时有效
|
|
10
|
+
feat: 增加了 onClearListener 选项,在清空侦听器时执行
|
|
11
|
+
fix: 修改了类型提示错误
|
|
12
|
+
|
|
13
|
+
## 1.1.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 02ffb88: 修改事件侦听器的接收为 FastEventMessage
|
|
18
|
+
|
|
3
19
|
## 1.0.4
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
6
22
|
|
|
7
|
-
-
|
|
23
|
+
- 3cf1e87: 更新 meta 泛型参数的位置
|
|
8
24
|
|
|
9
25
|
## 1.0.3
|
|
10
26
|
|
|
11
27
|
### Patch Changes
|
|
12
28
|
|
|
13
|
-
-
|
|
29
|
+
- 0c54b10: 调整 onAny 侦听器的执行优先级
|
|
14
30
|
|
|
15
31
|
## 1.0.2
|
|
16
32
|
|
|
17
33
|
### Patch Changes
|
|
18
34
|
|
|
19
|
-
-
|
|
35
|
+
- 02c6d3e: fix scope.on error
|
|
20
36
|
|
|
21
37
|
## 1.0.1
|
|
22
38
|
|
|
23
39
|
### Patch Changes
|
|
24
40
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
41
|
+
- b7d21e2: add prepend option for on
|
|
42
|
+
- 8807aaa: update scope on options
|
|
27
43
|
|
|
28
44
|
## 1.0.0
|
|
29
45
|
|
|
30
46
|
### Major Changes
|
|
31
47
|
|
|
32
|
-
-
|
|
48
|
+
- b8b8c13: first release
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一个基于弱引用(WeakRef)的键值映射集合
|
|
3
|
+
*
|
|
4
|
+
* @template T - 值的类型,必须是对象类型(继承自 `object`)
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const map = new WeakObjectMap<MyObject>();
|
|
8
|
+
* map.set('key1', obj1);
|
|
9
|
+
* const retrieved = map.get('key1'); // 返回 obj1 或 undefined(如果已被垃圾回收)
|
|
10
|
+
*/
|
|
11
|
+
declare class WeakObjectMap<T extends object> {
|
|
12
|
+
private map;
|
|
13
|
+
private finalizationRegistry;
|
|
14
|
+
/**
|
|
15
|
+
* 构造一个新的 WeakObjectMap 实例
|
|
16
|
+
*/
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* 设置键值对
|
|
20
|
+
* @param key - 字符串键名
|
|
21
|
+
* @param value - 要存储的对象值(会被自动包装为弱引用)
|
|
22
|
+
*/
|
|
23
|
+
set(key: string, value: T): void;
|
|
24
|
+
/**
|
|
25
|
+
* 获取指定键对应的值
|
|
26
|
+
* @param key - 要查找的键名
|
|
27
|
+
* @returns 如果值存在且未被垃圾回收则返回值,否则返回 undefined
|
|
28
|
+
*/
|
|
29
|
+
get(key: string): T | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 删除指定键的映射
|
|
32
|
+
* @param key - 要删除的键名
|
|
33
|
+
* @returns 如果键存在并已删除则返回 true,否则返回 false
|
|
34
|
+
*/
|
|
35
|
+
delete(key: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 检查是否存在指定键的映射(且值未被垃圾回收)
|
|
38
|
+
* @param key - 要检查的键名
|
|
39
|
+
* @returns 如果键存在且值未被回收则返回 true,否则返回 false
|
|
40
|
+
*/
|
|
41
|
+
has(key: string): boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type FastEventMessage<T = string, P = any, M = unknown> = {
|
|
45
|
+
type: T;
|
|
46
|
+
payload: P;
|
|
47
|
+
meta: M;
|
|
48
|
+
};
|
|
49
|
+
type FastEventListener<T = string, P = any, M = unknown> = (message: FastEventMessage<T, P, M>) => any | Promise<any>;
|
|
50
|
+
type FastListenerNode = {
|
|
51
|
+
__listeners: (FastEventListener<any, any, any> | [FastEventListener<any, any>, number])[];
|
|
52
|
+
} & {
|
|
53
|
+
[key: string]: FastListenerNode;
|
|
54
|
+
};
|
|
55
|
+
type FastEventSubscriber = {
|
|
56
|
+
off: () => void;
|
|
57
|
+
};
|
|
58
|
+
type FastListeners = FastListenerNode;
|
|
59
|
+
type FastEventOptions<M = unknown> = {
|
|
60
|
+
id?: string;
|
|
61
|
+
debug?: boolean;
|
|
62
|
+
delimiter?: string;
|
|
63
|
+
context?: any;
|
|
64
|
+
ignoreErrors?: boolean;
|
|
65
|
+
onListenerError?: ((type: string, error: Error) => void);
|
|
66
|
+
meta?: M;
|
|
67
|
+
onAddListener?: (type: string[], listener: FastEventListener) => void;
|
|
68
|
+
onRemoveListener?: (type: string[], listener: FastEventListener) => void;
|
|
69
|
+
onClearListeners?: () => void;
|
|
70
|
+
onExecuteListener?: (message: FastEventMessage, returns: any[], listeners: (FastEventListener<any, any, any> | [FastEventListener<any, any>, number])[]) => void;
|
|
71
|
+
};
|
|
72
|
+
type FastEvents = Record<string, any>;
|
|
73
|
+
type ScopeEvents<T extends Record<string, any>, Prefix extends string> = {
|
|
74
|
+
[K in keyof T as K extends `${Prefix}/${infer Rest}` ? Rest : never]: T[K];
|
|
75
|
+
};
|
|
76
|
+
type FastEventListenOptions = {
|
|
77
|
+
count?: number;
|
|
78
|
+
prepend?: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare class FastEventScope<Events extends FastEvents = FastEvents, Meta extends Record<string, any> = Record<string, any>, Types extends keyof Events = keyof Events> {
|
|
82
|
+
emitter: FastEvent<Events, Meta, Types>;
|
|
83
|
+
prefix: string;
|
|
84
|
+
constructor(emitter: FastEvent<Events, Meta, Types>, prefix: string);
|
|
85
|
+
private _getScopeListener;
|
|
86
|
+
private _getScopeType;
|
|
87
|
+
private _fixScopeType;
|
|
88
|
+
on<T extends Types = Types>(type: T, listener: FastEventListener<T, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
89
|
+
on<T extends string>(type: T, listener: FastEventListener<T, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
90
|
+
on(type: '**', listener: FastEventListener<any, any, Meta>): FastEventSubscriber;
|
|
91
|
+
once<T extends string>(type: T, listener: FastEventListener<T, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
92
|
+
once<T extends Types = Types>(type: T, listener: FastEventListener<Types, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
93
|
+
onAny<P = any>(listener: FastEventListener<Types, P, Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
94
|
+
offAll(): void;
|
|
95
|
+
off(listener: FastEventListener<any, any, any>): void;
|
|
96
|
+
off(type: string, listener: FastEventListener<any, any, any>): void;
|
|
97
|
+
off(type: Types, listener: FastEventListener<any, any, any>): void;
|
|
98
|
+
off(type: string): void;
|
|
99
|
+
off(type: Types): void;
|
|
100
|
+
clear(): void;
|
|
101
|
+
emit<R = any>(type: Types, payload?: Events[Types], retain?: boolean): R[];
|
|
102
|
+
emit<R = any>(type: string, payload?: any, retain?: boolean): R[];
|
|
103
|
+
waitFor<T extends Types, P = Events[T], M = Meta>(type: T, timeout?: number): Promise<FastEventMessage<T, P, M>>;
|
|
104
|
+
waitFor<T extends string, P = Events[T], M = Meta>(type: string, timeout?: number): Promise<FastEventMessage<T, P, M>>;
|
|
105
|
+
scope(prefix: string): FastEventScope<ScopeEvents<Events, string>, Record<string, any>, keyof ScopeEvents<Events, string>>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class FastEvent<Events extends FastEvents = FastEvents, Meta extends Record<string, any> = Record<string, any>, Types extends keyof Events = keyof Events> {
|
|
109
|
+
listeners: FastListeners;
|
|
110
|
+
private _options;
|
|
111
|
+
private _delimiter;
|
|
112
|
+
private _context;
|
|
113
|
+
retainedMessages: Map<string, any>;
|
|
114
|
+
listenerCount: number;
|
|
115
|
+
constructor(options?: FastEventOptions<Meta>);
|
|
116
|
+
get options(): FastEventOptions;
|
|
117
|
+
get id(): string;
|
|
118
|
+
private _addListener;
|
|
119
|
+
private _enableDevTools;
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* 根据parts路径遍历侦听器树,并在最后的节点上执行回调函数
|
|
123
|
+
*
|
|
124
|
+
* @param parts
|
|
125
|
+
* @param callback
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
private _forEachNodes;
|
|
129
|
+
/**
|
|
130
|
+
* 从监听器节点中移除指定的事件监听器
|
|
131
|
+
* @private
|
|
132
|
+
* @param node - 监听器节点
|
|
133
|
+
* @param listener - 需要移除的事件监听器
|
|
134
|
+
* @description 遍历节点的监听器列表,移除所有匹配的监听器。支持移除普通函数和数组形式的监听器
|
|
135
|
+
*/
|
|
136
|
+
private _removeListener;
|
|
137
|
+
on<T extends string>(type: T, listener: FastEventListener<T, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
138
|
+
on<T extends Types = Types>(type: T, listener: FastEventListener<Types, Events[T], Meta>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
139
|
+
on<P = any>(type: '**', listener: FastEventListener<Types, P, Meta>): FastEventSubscriber;
|
|
140
|
+
once<T extends Types = Types>(type: T, listener: FastEventListener<T, Events[T], Meta>): FastEventSubscriber;
|
|
141
|
+
once<T extends string>(type: T, listener: FastEventListener<T, Events[T], Meta>): FastEventSubscriber;
|
|
142
|
+
/**
|
|
143
|
+
* 注册一个监听器,用于监听所有事件
|
|
144
|
+
* @param listener 事件监听器函数,可以接收任意类型的事件数据
|
|
145
|
+
* @returns {FastEventSubscriber} 返回一个订阅者对象,包含 off 方法用于取消监听
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const subscriber = emitter.onAny((eventName, data) => {
|
|
149
|
+
* console.log(eventName, data);
|
|
150
|
+
* });
|
|
151
|
+
*
|
|
152
|
+
* // 取消监听
|
|
153
|
+
* subscriber.off();
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
onAny<P = any>(listener: FastEventListener<string, P, Meta>, options?: Pick<FastEventListenOptions, 'prepend'>): FastEventSubscriber;
|
|
157
|
+
off(listener: FastEventListener<any, any, any>): void;
|
|
158
|
+
off(type: string, listener: FastEventListener<any, any, any>): void;
|
|
159
|
+
off(type: Types, listener: FastEventListener<any, any, any>): void;
|
|
160
|
+
off(type: string): void;
|
|
161
|
+
off(type: Types): void;
|
|
162
|
+
/**
|
|
163
|
+
* 移除所有事件监听器
|
|
164
|
+
* @param entry - 可选的事件前缀,如果提供则只移除指定前缀下的的监听器
|
|
165
|
+
* @description
|
|
166
|
+
* - 如果提供了prefix参数,则只清除该前缀下的所有监听器
|
|
167
|
+
* - 如果没有提供prefix,则清除所有监听器
|
|
168
|
+
* - 同时会清空保留的事件(_retainedEvents)
|
|
169
|
+
* - 重置监听器对象为空
|
|
170
|
+
|
|
171
|
+
* @example
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* emitter.offAll(); // 清除所有监听器
|
|
175
|
+
* emitter.offAll('a/b'); // 清除a/b下的所有监听器
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
offAll(entry?: string): void;
|
|
179
|
+
private _getListenerNode;
|
|
180
|
+
/**
|
|
181
|
+
* 移除保留的事件
|
|
182
|
+
* @param prefix - 事件前缀。如果不提供,将清除所有保留的事件。
|
|
183
|
+
* 如果提供前缀,将删除所有以该前缀开头的事件。
|
|
184
|
+
* 如果前缀不以分隔符结尾,会自动添加分隔符。
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
private _removeRetainedEvents;
|
|
188
|
+
clear(): void;
|
|
189
|
+
private _createMeta;
|
|
190
|
+
private _emitForLastEvent;
|
|
191
|
+
/**
|
|
192
|
+
* 遍历监听器节点树
|
|
193
|
+
* @param node 当前遍历的监听器节点
|
|
194
|
+
* @param parts 事件名称按'.'分割的部分数组
|
|
195
|
+
* @param callback 遍历到目标节点时的回调函数
|
|
196
|
+
* @param index 当前遍历的parts数组索引,默认为0
|
|
197
|
+
* @param lastFollowing 当命中**时该值为true, 注意**只能作在路径的最后面,如a.**有效,而a.**.b无效
|
|
198
|
+
* @private
|
|
199
|
+
*
|
|
200
|
+
* 支持三种匹配模式:
|
|
201
|
+
* - 精确匹配: 'a.b.c'
|
|
202
|
+
* - 单层通配: 'a.*.c'
|
|
203
|
+
* - 多层通配: 'a.**'
|
|
204
|
+
*/
|
|
205
|
+
private _traverseToPath;
|
|
206
|
+
private _traverseListeners;
|
|
207
|
+
private _executeListener;
|
|
208
|
+
/**
|
|
209
|
+
* 执行监听器节点中的所有监听函数
|
|
210
|
+
* @param node - FastListenerNode类型的监听器节点
|
|
211
|
+
* @param payload - 事件携带的数据
|
|
212
|
+
* @param type - 事件类型
|
|
213
|
+
* @returns 返回所有监听函数的执行结果数组
|
|
214
|
+
* @private
|
|
215
|
+
*
|
|
216
|
+
* @description
|
|
217
|
+
* 遍历执行节点中的所有监听函数:
|
|
218
|
+
* - 对于普通监听器,直接执行并收集结果
|
|
219
|
+
* - 对于带次数限制的监听器(数组形式),执行后递减次数,当次数为0时移除该监听器
|
|
220
|
+
*/
|
|
221
|
+
private _executeListeners;
|
|
222
|
+
/**
|
|
223
|
+
* 触发事件并执行对应的监听器
|
|
224
|
+
*
|
|
225
|
+
* @param type - 事件类型字符串或包含事件信息的对象
|
|
226
|
+
* @param payload - 事件携带的数据负载
|
|
227
|
+
* @param retain - 是否保留该事件(用于新订阅者)
|
|
228
|
+
* @param meta - 事件元数据
|
|
229
|
+
* @returns 所有监听器的执行结果数组
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* // 方式1: 参数形式
|
|
233
|
+
* emit('user.login', { id: 1 }, true)
|
|
234
|
+
*
|
|
235
|
+
* // 方式2: 对象形式
|
|
236
|
+
* emit({ type: 'user.login', payload: { id: 1 } ,meta:{...}}}, true)
|
|
237
|
+
*/
|
|
238
|
+
emit<R = any>(type: string, payload?: any, retain?: boolean, meta?: Meta): R[];
|
|
239
|
+
emit<R = any>(type: Types, payload?: Events[Types], retain?: boolean, meta?: Meta): R[];
|
|
240
|
+
emit<R = any>(message: FastEventMessage<Types, Events[Types], Meta>, retain?: boolean): R[];
|
|
241
|
+
emit<R = any>(message: FastEventMessage<string, any, Meta>, retain?: boolean): R[];
|
|
242
|
+
emitAsync<R = any>(type: string, payload?: any, retain?: boolean, meta?: Meta): Promise<[R | Error][]>;
|
|
243
|
+
emitAsync<R = any>(type: Types, payload?: Events[Types], retain?: boolean, meta?: Meta): Promise<[R | Error][]>;
|
|
244
|
+
/**
|
|
245
|
+
* 等待指定事件发生
|
|
246
|
+
*
|
|
247
|
+
* waitFor("x")
|
|
248
|
+
*
|
|
249
|
+
* @param type
|
|
250
|
+
* @param timeout 超时时间,单位毫秒,默认为 0,表示无限等待
|
|
251
|
+
*/
|
|
252
|
+
waitFor<T extends Types, P = Events[T], M = Meta>(type: T, timeout?: number): Promise<FastEventMessage<T, P, M>>;
|
|
253
|
+
waitFor<T extends string, P = Events[T], M = Meta>(type: string, timeout?: number): Promise<FastEventMessage<T, P, M>>;
|
|
254
|
+
/**
|
|
255
|
+
* 创建事件域
|
|
256
|
+
*
|
|
257
|
+
* 注意:
|
|
258
|
+
*
|
|
259
|
+
* 事件域与当前事件对象共享相同的侦听器表
|
|
260
|
+
* 也就是说,如果在事件域中触发事件,当前事件对象也会触发该事件
|
|
261
|
+
* 两者工不是完全隔离的,仅是事件侦听和触发时的事件类型不同而已
|
|
262
|
+
*
|
|
263
|
+
* const emitter = new FastEvent()
|
|
264
|
+
*
|
|
265
|
+
* const scope= emitter.scope("a/b")
|
|
266
|
+
*
|
|
267
|
+
* scope.on("x",()=>{}) == emitter.on("a/b/x",()=>{})
|
|
268
|
+
* scope.emit("x",1) == emitter.emit("a/b/x",1)
|
|
269
|
+
* scope.offAll() == emitter.offAll("a/b")
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
272
|
+
scope<T extends string>(prefix: T): FastEventScope<ScopeEvents<Events, T>, Record<string, any>, keyof ScopeEvents<Events, T>>;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
*
|
|
277
|
+
* 基于开发工具
|
|
278
|
+
*
|
|
279
|
+
* Redux DevTools 是一个实用工具,用于开发和调试 Redux 应用程序。
|
|
280
|
+
* FLEXEVENT是基于Redux DevTools 的简单包装,可以让开发者使用Redux DevTools
|
|
281
|
+
* 来查看FLEXEVENT的状态变化
|
|
282
|
+
*
|
|
283
|
+
* import { createStore } from "@FLEXEVENTjs/react"
|
|
284
|
+
* import { install } from "@FLEXEVENTjs/devtools"
|
|
285
|
+
*
|
|
286
|
+
*
|
|
287
|
+
* const store = createStore({})
|
|
288
|
+
*
|
|
289
|
+
* install()
|
|
290
|
+
*
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
declare class FlexEventDevTools {
|
|
294
|
+
private reduxStore;
|
|
295
|
+
private _installed;
|
|
296
|
+
fastEvents: WeakObjectMap<object>;
|
|
297
|
+
constructor();
|
|
298
|
+
add(instance: FastEvent): void;
|
|
299
|
+
remove(instance: FastEvent): void;
|
|
300
|
+
private reducer;
|
|
301
|
+
private install;
|
|
302
|
+
}
|
|
303
|
+
declare function install(): void;
|
|
304
|
+
declare global {
|
|
305
|
+
var __FLEXEVENT_DEVTOOLS__: FlexEventDevTools;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export { FlexEventDevTools, install };
|