fastevent 2.2.12 → 2.3.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/dist/eventbus/index.d.mts +141 -39
- package/dist/eventbus/index.d.ts +141 -39
- package/dist/eventbus/index.js +1 -1
- package/dist/eventbus/index.js.map +1 -1
- package/dist/eventbus/index.mjs +1 -1
- package/dist/eventbus/index.mjs.map +1 -1
- package/dist/executors/index.d.mts +15 -3
- package/dist/executors/index.d.ts +15 -3
- package/dist/index.d.mts +139 -37
- package/dist/index.d.ts +139 -37
- 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/dist/pipes/index.d.mts +15 -3
- package/dist/pipes/index.d.ts +15 -3
- package/package.json +1 -1
|
@@ -2,6 +2,18 @@ type FastListenerExecutor = (listeners: FastListenerMeta[], message: TypedFastEv
|
|
|
2
2
|
|
|
3
3
|
type FastListenerPipe = (listener: TypedFastEventListener) => TypedFastEventListener;
|
|
4
4
|
|
|
5
|
+
type Expand$1<T> = T extends infer O ? {
|
|
6
|
+
[K in keyof O]: O[K];
|
|
7
|
+
} : never;
|
|
8
|
+
type ContainsWildcard<T extends string> = T extends `${string}/*/${string}` ? true : T extends `${string}/*` ? true : T extends `*/${string}` ? true : T extends `*` ? true : false;
|
|
9
|
+
type ReplaceWildcard<T extends string> = T extends `*${infer Rest}` ? `${string}${ReplaceWildcard<Rest>}` : T extends `${infer Head}*${infer Rest}` ? `${Head}${string}${ReplaceWildcard<Rest>}` : T;
|
|
10
|
+
type WildcardKeys<T> = {
|
|
11
|
+
[K in keyof T]: K extends string ? (ContainsWildcard<K> extends true ? K : never) : never;
|
|
12
|
+
}[keyof T];
|
|
13
|
+
type ExpandWildcard<T extends Record<string, any>> = Expand$1<T & {
|
|
14
|
+
[K in WildcardKeys<T> as ReplaceWildcard<K>]: T[K];
|
|
15
|
+
}>;
|
|
16
|
+
|
|
5
17
|
type MergeUnion<T> = (T extends any ? (x: T) => void : never) extends (x: infer U) => void ? {
|
|
6
18
|
[K in keyof U]: U[K];
|
|
7
19
|
} : never;
|
|
@@ -16,9 +28,10 @@ type MatchEventType<T extends string, Events extends Record<string, any>> = Merg
|
|
|
16
28
|
[K in keyof Events]: MatchPattern<T, K & string> extends never ? never : {
|
|
17
29
|
[P in K]: Events[K];
|
|
18
30
|
};
|
|
19
|
-
}[keyof Events] extends infer Result ? Result extends Record<string, any> ? Result : any :
|
|
31
|
+
}[keyof Events] extends infer Result ? Result extends Record<string, any> ? Result : Record<string, any> : Record<string, any>, {
|
|
20
32
|
[K in T]: any;
|
|
21
33
|
}>>;
|
|
34
|
+
type MatchEventPayload<Events extends Record<string, any>, T> = T extends keyof Events ? Events[T] : T extends string ? T extends keyof MatchEventType<T, Events> ? MatchEventType<T, Events>[T] : any : any;
|
|
22
35
|
|
|
23
36
|
type Split<S extends string, Delimiter extends string> = S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : [S];
|
|
24
37
|
type MatchPatternAndGetRemainder<KeyParts extends string[], PrefixParts extends string[], Result extends string[] = []> = PrefixParts['length'] extends 0 ? KeyParts['length'] extends 0 ? never : KeyParts : KeyParts['length'] extends 0 ? never : KeyParts[0] extends PrefixParts[0] | '*' ? MatchPatternAndGetRemainder<Slice<KeyParts, 1>, Slice<PrefixParts, 1>, Result> : never;
|
|
@@ -59,9 +72,11 @@ type FastEventEmitMessage<Events extends Record<string, any> = Record<string, an
|
|
|
59
72
|
meta?: DeepPartial<FastEventMeta & M & Record<string, any>>;
|
|
60
73
|
};
|
|
61
74
|
}[Exclude<keyof Events, number | symbol>] & FastEventMessageExtends;
|
|
62
|
-
type
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
type FastMessagePayload<P = any> = {
|
|
76
|
+
type: P;
|
|
77
|
+
__IS_FAST_MESSAGE__: true;
|
|
78
|
+
};
|
|
79
|
+
type TypedFastEventListener<T extends string = string, P = any, M = any, C = any> = (this: C, message: TypedFastEventMessage<Record<T, P>, M>, args: FastEventListenerArgs<M>) => any | Promise<any>;
|
|
65
80
|
type TypedFastEventAnyListener<Events extends Record<string, any> = Record<string, any>, Meta = never, Context = any> = (this: Context, message: TypedFastEventMessage<Events, Meta>, args: FastEventListenerArgs<Meta>) => any | Promise<any>;
|
|
66
81
|
type FastEventListeners<Events extends Record<string, any> = Record<string, any>, M = any, C = any> = {
|
|
67
82
|
[K in keyof Events]: TypedFastEventListener<Exclude<K, number | symbol>, Events[K], M, C>;
|
|
@@ -134,6 +149,16 @@ type FastEventOptions<Meta = Record<string, any>, Context = never> = {
|
|
|
134
149
|
executor?: FastListenerExecutor;
|
|
135
150
|
onMessage?: TypedFastEventListener;
|
|
136
151
|
expandEmitResults?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* 对接收到的消息进行转换,用于将消息转换成其他格式
|
|
154
|
+
*
|
|
155
|
+
* new FastEvent({
|
|
156
|
+
* transform:(message)=>{
|
|
157
|
+
* message.payload
|
|
158
|
+
* }
|
|
159
|
+
* })
|
|
160
|
+
*/
|
|
161
|
+
transform?: (message: FastEventMessage) => any;
|
|
137
162
|
};
|
|
138
163
|
interface FastEvents {
|
|
139
164
|
}
|
|
@@ -151,6 +176,9 @@ type FastEventListenOptions<Events extends Record<string, any> = Record<string,
|
|
|
151
176
|
*/
|
|
152
177
|
tag?: string;
|
|
153
178
|
};
|
|
179
|
+
declare enum FastEventListenerFlags {
|
|
180
|
+
Transformed = 1
|
|
181
|
+
}
|
|
154
182
|
type FastEventListenerArgs<M = Record<string, any>> = {
|
|
155
183
|
retain?: boolean;
|
|
156
184
|
meta?: DeepPartial<M> & Record<string, any>;
|
|
@@ -167,6 +195,17 @@ type FastEventListenerArgs<M = Record<string, any>> = {
|
|
|
167
195
|
* 当emit参数解析完成后的回调,用于修改emit参数
|
|
168
196
|
*/
|
|
169
197
|
parseArgs?: (message: TypedFastEventMessage, args: FastEventListenerArgs) => void;
|
|
198
|
+
/**
|
|
199
|
+
* 额外的标识
|
|
200
|
+
*
|
|
201
|
+
* - 1: transformed 当消息是经过transform转换后的消息时的标识
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
flags?: FastEventListenerFlags;
|
|
205
|
+
/**
|
|
206
|
+
* 如果消息经过转换前的原主题
|
|
207
|
+
*/
|
|
208
|
+
rawEventType?: string;
|
|
170
209
|
};
|
|
171
210
|
type Merge<T extends object, U extends object> = {
|
|
172
211
|
[K in keyof T | keyof U]: K extends keyof U ? U[K] : K extends keyof T ? T[K] : never;
|
|
@@ -256,6 +295,52 @@ type RecordValues<R extends Record<string, any>> = R[keyof R];
|
|
|
256
295
|
type RecordPrefix<P extends string, R extends Record<string, any>> = {
|
|
257
296
|
[K in keyof R as K extends `${P}/${infer S}` ? S : never]: R[K];
|
|
258
297
|
};
|
|
298
|
+
/**
|
|
299
|
+
* 声明事件类型时,一般情况下,K=事件名称,V=事件Payload参数类型
|
|
300
|
+
*
|
|
301
|
+
* AssertFastMessage用于声明V是一个FastMessage类型,而不是Payload类型
|
|
302
|
+
*
|
|
303
|
+
* 一般配合transform参数使用
|
|
304
|
+
*
|
|
305
|
+
* 例如:
|
|
306
|
+
* type CustomEvents = {
|
|
307
|
+
click: { x: number; y: number };
|
|
308
|
+
}
|
|
309
|
+
const emitter = new FastEvent<CustomEvents>();
|
|
310
|
+
emitter.on('click', (message) => {
|
|
311
|
+
// typeof message.payload === { x: number; y: number }
|
|
312
|
+
})
|
|
313
|
+
const emitter = new FastEvent<CustomEvents>({
|
|
314
|
+
transform:(message)=>{
|
|
315
|
+
if(message.type === 'click'){
|
|
316
|
+
return message.payload
|
|
317
|
+
}else{
|
|
318
|
+
return message
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
emitter.on('click', (message) => {
|
|
323
|
+
// typeof message === { x: number; y: number }
|
|
324
|
+
}
|
|
325
|
+
*/
|
|
326
|
+
type AssertFastMessage<M> = {
|
|
327
|
+
type: M;
|
|
328
|
+
__IS_FAST_MESSAGE__: true;
|
|
329
|
+
};
|
|
330
|
+
type NotPayload<M> = AssertFastMessage<M>;
|
|
331
|
+
type PickPayload<M> = M extends FastMessagePayload ? M['type'] : M;
|
|
332
|
+
type AtPayloads<Events extends Record<string, any>> = {
|
|
333
|
+
[K in keyof Events]: PickPayload<Events[K]>;
|
|
334
|
+
};
|
|
335
|
+
type PickTransformedEvents<T extends Record<string, any>> = ExpandWildcard<{
|
|
336
|
+
[key in keyof T as T[key] extends FastMessagePayload ? key : never]: T[key];
|
|
337
|
+
}>;
|
|
338
|
+
type OmitTransformedEvents<T extends Record<string, any>> = {
|
|
339
|
+
[key in keyof T as T[key] extends FastMessagePayload ? never : key]: T[key];
|
|
340
|
+
};
|
|
341
|
+
type TransformedEvents<Events extends Record<string, any>> = {
|
|
342
|
+
[K in keyof Events]: NotPayload<Events[K]>;
|
|
343
|
+
};
|
|
259
344
|
|
|
260
345
|
type FastEventBusMessage<Events extends Record<string, any> = Record<string, any>, M = any> = FastEventEmitMessage<Events, M> & {
|
|
261
346
|
from?: string;
|
|
@@ -277,6 +362,16 @@ type FastEventScopeOptions<Meta = Record<string, any>, Context = never> = {
|
|
|
277
362
|
context: Context;
|
|
278
363
|
executor?: FastListenerExecutor;
|
|
279
364
|
onMessage?: TypedFastEventListener;
|
|
365
|
+
/**
|
|
366
|
+
* 对接收到的消息进行转换,用于将消息转换成其他格式
|
|
367
|
+
*
|
|
368
|
+
* new FastEvent({
|
|
369
|
+
* transform:(message)=>{
|
|
370
|
+
* message.payload
|
|
371
|
+
* }
|
|
372
|
+
* })
|
|
373
|
+
*/
|
|
374
|
+
transform?: (message: FastEventMessage) => any;
|
|
280
375
|
};
|
|
281
376
|
interface FastEventScopeMeta {
|
|
282
377
|
scope: string;
|
|
@@ -318,15 +413,17 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
|
|
|
318
413
|
private _getScopeType;
|
|
319
414
|
private _fixScopeType;
|
|
320
415
|
on<T extends Types = Types>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
|
|
321
|
-
on<T extends string
|
|
416
|
+
on<T extends Exclude<string, Types>>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
|
|
322
417
|
on(type: '**', options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
|
|
323
|
-
on<T extends
|
|
324
|
-
on<T extends
|
|
418
|
+
on<T extends keyof OmitTransformedEvents<Events>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, Events[T], FinalMeta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
419
|
+
on<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<MatchEventType<Exclude<T, number | symbol>, Events>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
|
|
420
|
+
on<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<MatchEventType<T, Events>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
325
421
|
on(type: '**', listener: TypedFastEventAnyListener<Events, FinalMeta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
326
422
|
once<T extends Types = Types>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
|
|
327
|
-
once<T extends string
|
|
328
|
-
once<T extends
|
|
329
|
-
once<T extends
|
|
423
|
+
once<T extends Exclude<string, Types>>(type: T, options?: FastEventListenOptions<Events, FinalMeta>): FastEventSubscriber;
|
|
424
|
+
once<T extends keyof OmitTransformedEvents<Events>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, Events[T], FinalMeta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
425
|
+
once<T extends keyof PickTransformedEvents<Events>>(type: T, listener: (message: PickPayload<RecordValues<MatchEventType<Exclude<T, number | symbol>, Events>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<Events, Meta>): FastEventSubscriber;
|
|
426
|
+
once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<MatchEventType<T, Events>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions): FastEventSubscriber;
|
|
330
427
|
onAny(options?: Pick<FastEventListenOptions, 'prepend'>): FastEventSubscriber;
|
|
331
428
|
onAny<P = any>(listener: TypedFastEventAnyListener<{
|
|
332
429
|
[K: string]: P;
|
|
@@ -340,19 +437,21 @@ declare class FastEventScope<Events extends Record<string, any> = Record<string,
|
|
|
340
437
|
clear(): void;
|
|
341
438
|
emit(type: Types, directive: symbol): void;
|
|
342
439
|
emit(type: string, directive: symbol): void;
|
|
343
|
-
emit<R = any, T extends Types = Types>(type: T, payload?: Events[T]
|
|
344
|
-
emit<R = any, T extends string = string>(type: T, payload?: T extends Types ? Events[T] : RecordValues<MatchEventType<T, Events
|
|
345
|
-
emit<R = any>(type:
|
|
346
|
-
emit<R = any
|
|
347
|
-
emit<R = any>(message: FastEventEmitMessage<Events, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
|
|
440
|
+
emit<R = any, T extends Types = Types>(type: T, payload?: PickPayload<Events[T]>, retain?: boolean): R[];
|
|
441
|
+
emit<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? Events[T] : RecordValues<MatchEventType<T, Events>>>, retain?: boolean): R[];
|
|
442
|
+
emit<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? Events[T] : RecordValues<MatchEventType<T, Events>>>, options?: FastEventListenerArgs<FinalMeta>): R[];
|
|
443
|
+
emit<R = any>(message: FastEventEmitMessage<AtPayloads<Events>, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
|
|
348
444
|
emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
349
|
-
[K in T]: K extends Types ? Events[K] : any
|
|
445
|
+
[K in T]: PickPayload<K extends Types ? Events[K] : any>;
|
|
350
446
|
}, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): R[];
|
|
351
|
-
|
|
352
|
-
emitAsync<R = any, T extends
|
|
353
|
-
emitAsync<R = any, T extends
|
|
354
|
-
emitAsync<R = any, T extends
|
|
355
|
-
emitAsync<R = any>(
|
|
447
|
+
private _transformMessage;
|
|
448
|
+
emitAsync<R = any, T extends Types = Types>(type: T, payload?: PickPayload<Events[T]>, retain?: boolean): Promise<[R | Error][]>;
|
|
449
|
+
emitAsync<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? Events[T] : any>, retain?: boolean): Promise<[R | Error][]>;
|
|
450
|
+
emitAsync<R = any, T extends Types = Types>(type: T, payload?: PickPayload<Events[T]>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
|
|
451
|
+
emitAsync<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? Events[T] : any>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
|
|
452
|
+
emitAsync<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
453
|
+
[K in T]: PickPayload<K extends Types ? Events[K] : any>;
|
|
454
|
+
}, FinalMeta>, options?: FastEventListenerArgs<FinalMeta>): Promise<[R | Error][]>;
|
|
356
455
|
waitFor<T extends Types>(type: T, timeout?: number): Promise<TypedFastEventMessage<{
|
|
357
456
|
[key in T]: Events[T];
|
|
358
457
|
}, FinalMeta>>;
|
|
@@ -516,8 +615,9 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
516
615
|
on<T extends Types = Types>(type: T, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
517
616
|
on<T extends string>(type: T, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
518
617
|
on(type: '**', options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
519
|
-
on<T extends
|
|
520
|
-
on<T extends
|
|
618
|
+
on<T extends keyof OmitTransformedEvents<AllEvents>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, AllEvents[T], Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
619
|
+
on<T extends keyof PickTransformedEvents<AllEvents>>(type: T, listener: (message: PickPayload<RecordValues<MatchEventType<Exclude<T, number | symbol>, AllEvents>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
620
|
+
on<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<MatchEventType<T, AllEvents>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
521
621
|
on(type: '**', listener: TypedFastEventAnyListener<Record<string, any>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
522
622
|
/**
|
|
523
623
|
* 注册一次性事件监听器
|
|
@@ -542,8 +642,9 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
542
642
|
*/
|
|
543
643
|
once<T extends Types = Types>(type: T, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
544
644
|
once<T extends string>(type: T, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
545
|
-
once<T extends
|
|
546
|
-
once<T extends
|
|
645
|
+
once<T extends keyof OmitTransformedEvents<AllEvents>>(type: T, listener: TypedFastEventListener<Exclude<T, number | symbol>, AllEvents[T], Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
646
|
+
once<T extends keyof PickTransformedEvents<AllEvents>>(type: T, listener: (message: PickPayload<RecordValues<MatchEventType<Exclude<T, number | symbol>, AllEvents>>>, args: FastEventListenerArgs<Meta>) => any | Promise<any>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
647
|
+
once<T extends Exclude<string, Types>>(type: T, listener: TypedFastEventAnyListener<MatchEventType<T, AllEvents>, Meta, Fallback<Context, typeof this>>, options?: FastEventListenOptions<AllEvents, Meta>): FastEventSubscriber;
|
|
547
648
|
/**
|
|
548
649
|
* 注册一个监听器,用于监听所有事件
|
|
549
650
|
* @param listener 事件监听器函数,可以接收任意类型的事件数据
|
|
@@ -629,6 +730,7 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
629
730
|
private _traverseToPath;
|
|
630
731
|
private _traverseListeners;
|
|
631
732
|
private _onListenerError;
|
|
733
|
+
private _setListenerFlags;
|
|
632
734
|
/**
|
|
633
735
|
* 执行单个监听器函数
|
|
634
736
|
* @param listener - 要执行的监听器函数或包装过的监听器对象
|
|
@@ -731,16 +833,16 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
731
833
|
*/
|
|
732
834
|
emit<T extends Types = Types>(type: T, directive: symbol): any[];
|
|
733
835
|
emit(type: string, directive: symbol): any[];
|
|
734
|
-
emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T]
|
|
735
|
-
emit<R = any, T extends string = string>(type: T, payload
|
|
836
|
+
emit<R = any, T extends Types = Types>(type: T, payload?: PickPayload<AllEvents[T]>, retain?: boolean): R[];
|
|
837
|
+
emit<R = any, T extends string = string>(type: T, payload: PickPayload<T extends Types ? AllEvents[T] : RecordValues<MatchEventType<T, AllEvents>>>, retain?: boolean): R[];
|
|
736
838
|
emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
737
839
|
[K in T]: K extends Types ? AllEvents[K] : any;
|
|
738
840
|
}, Meta>, retain?: boolean): R[];
|
|
739
841
|
emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): R[];
|
|
740
|
-
emit<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T]
|
|
741
|
-
emit<R = any, T extends string = string>(type: T, payload
|
|
842
|
+
emit<R = any, T extends Types = Types>(type: T, payload?: PickPayload<AllEvents[T]>, options?: FastEventListenerArgs<Meta>): R[];
|
|
843
|
+
emit<R = any, T extends string = string>(type: T, payload: PickPayload<T extends Types ? AllEvents[T] : RecordValues<MatchEventType<T, AllEvents>>>, options?: FastEventListenerArgs<Meta>): R[];
|
|
742
844
|
emit<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
743
|
-
[K in T]: K extends Types ? AllEvents[K] : any
|
|
845
|
+
[K in T]: PickPayload<K extends Types ? AllEvents[K] : any>;
|
|
744
846
|
}, Meta>, options?: FastEventListenerArgs<Meta>): R[];
|
|
745
847
|
emit<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, options?: FastEventListenerArgs<Meta>): R[];
|
|
746
848
|
/**
|
|
@@ -779,16 +881,16 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
779
881
|
* });
|
|
780
882
|
* ```
|
|
781
883
|
*/
|
|
782
|
-
emitAsync<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T]
|
|
783
|
-
emitAsync<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any
|
|
884
|
+
emitAsync<R = any, T extends Types = Types>(type: T, payload?: PickPayload<AllEvents[T]>, retain?: boolean): Promise<[R | Error][]>;
|
|
885
|
+
emitAsync<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? AllEvents[T] : any>, retain?: boolean): Promise<[R | Error][]>;
|
|
784
886
|
emitAsync<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
785
|
-
[K in T]: K extends Types ? AllEvents[K] : any
|
|
887
|
+
[K in T]: PickPayload<K extends Types ? AllEvents[K] : any>;
|
|
786
888
|
}, Meta>, retain?: boolean): Promise<[R | Error][]>;
|
|
787
889
|
emitAsync<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, retain?: boolean): Promise<[R | Error][]>;
|
|
788
|
-
emitAsync<R = any, T extends string = string>(type: T, payload?: T extends Types ? AllEvents[T] : any
|
|
789
|
-
emitAsync<R = any, T extends Types = Types>(type: T, payload?: AllEvents[T]
|
|
890
|
+
emitAsync<R = any, T extends string = string>(type: T, payload?: PickPayload<T extends Types ? AllEvents[T] : any>, options?: FastEventListenerArgs<Meta>): Promise<[R | Error][]>;
|
|
891
|
+
emitAsync<R = any, T extends Types = Types>(type: T, payload?: PickPayload<AllEvents[T]>, options?: FastEventListenerArgs<Meta>): Promise<[R | Error][]>;
|
|
790
892
|
emitAsync<R = any, T extends string = string>(message: FastEventEmitMessage<{
|
|
791
|
-
[K in T]: K extends Types ? AllEvents[K] : any
|
|
893
|
+
[K in T]: PickPayload<K extends Types ? AllEvents[K] : any>;
|
|
792
894
|
}, Meta>, options?: FastEventListenerArgs<Meta>): Promise<[R | Error][]>;
|
|
793
895
|
emitAsync<R = any>(message: FastEventEmitMessage<AllEvents, Meta>, options?: FastEventListenerArgs<Meta>): Promise<[R | Error][]>;
|
|
794
896
|
/**
|
|
@@ -878,7 +980,7 @@ declare class FastEvent<Events extends Record<string, any> = Record<string, any>
|
|
|
878
980
|
|
|
879
981
|
type FastEventBusNodeOptions<Meta = Record<string, any>, Context = any> = FastEventOptions<Meta, Context> & {};
|
|
880
982
|
declare class FastEventBusNode<Events extends Record<string, any> = Record<string, any>, Meta extends Record<string, any> = Record<string, any>, Context = never> extends FastEvent<Events, Meta, Context> {
|
|
881
|
-
eventbus?: FastEventBus<any, any, any>;
|
|
983
|
+
eventbus?: FastEventBus<any, any, any, any, any>;
|
|
882
984
|
private _subscribers;
|
|
883
985
|
constructor(options?: DeepPartial<FastEventBusNodeOptions<Meta, Context>>);
|
|
884
986
|
/**
|
|
@@ -904,7 +1006,7 @@ declare class FastEventBusNode<Events extends Record<string, any> = Record<strin
|
|
|
904
1006
|
* 加入事件总线
|
|
905
1007
|
* @param eventBus 要加入的事件总线
|
|
906
1008
|
*/
|
|
907
|
-
connect(eventbus: FastEventBus<
|
|
1009
|
+
connect<E extends Record<string, any> = Record<string, any>, M extends Record<string, any> = Record<string, any>, C = any>(eventbus: FastEventBus<E, M, C>): void;
|
|
908
1010
|
disconnect(): void;
|
|
909
1011
|
/**
|
|
910
1012
|
*
|
|
@@ -1132,4 +1234,4 @@ declare function isClass(target: unknown): target is new (...args: any[]) => any
|
|
|
1132
1234
|
|
|
1133
1235
|
declare function isFastEvent(target: any): target is FastEvent;
|
|
1134
1236
|
|
|
1135
|
-
export { AbortError, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type MatchEventType, type Merge, type MergeUnion, NamespaceDelimiter, NodeDataEvent, type ObjectKeys, type OptionalItems, type Overloads, type OverrideOptions, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Union, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
|
|
1237
|
+
export { AbortError, type AssertFastMessage, type AtPayloads, BroadcastEvent, CancelError, type ChangeFieldType, type DeepPartial, type Dict, type Expand, type ExpandWildcard, type Fallback, FastEvent, FastEventBus, type FastEventBusEventTypes, type FastEventBusEvents, type FastEventBusMessage, FastEventBusNode, type FastEventBusNodeIds, type FastEventBusNodeOptions, type FastEventBusNodes, type FastEventBusOptions, FastEventDirectives, type FastEventEmitMessage, FastEventError, type FastEventListenOptions, type FastEventListener, type FastEventListenerArgs, FastEventListenerFlags, type FastEventListeners, type FastEventMessage, type FastEventMessageExtends, type FastEventMeta, type FastEventOptions, FastEventScope, type FastEventScopeMeta, type FastEventScopeOptions, type FastEventSubscriber, type FastEvents, type FastListenerMeta, type FastListenerNode, type FastListeners, type FastMessagePayload, type MatchEventPayload, type MatchEventType, type Merge, type MergeUnion, NamespaceDelimiter, NodeDataEvent, type NotPayload, type ObjectKeys, type OmitTransformedEvents, type OptionalItems, type Overloads, type OverrideOptions, type PickPayload, type PickTransformedEvents, QueueOverflowError, type RecordPrefix, type RecordValues, type RequiredItems, type ScopeEvents, TimeoutError, type TransformedEvents, type TypedFastEventAnyListener, type TypedFastEventListener, type TypedFastEventMessage, type TypedFastEventMessageOptional, UnboundError, type Union, type Unique, __FastEventScope__, __FastEvent__, __expandable__, expandable, isClass, isExpandable, isFastEvent, isFastEventMessage, isFastEventScope, isFunction, isPathMatched, isString, isSubsctiber };
|