vue-fn 0.1.0-beta.2 → 0.1.0-rc.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/domain/agg.d.ts CHANGED
@@ -7,7 +7,7 @@ type AddDestroyedEventApi<T extends object, K = 'destroyed'> = keyof T extends n
7
7
  } & {
8
8
  destroyed: DomainDestroyedEventApi;
9
9
  };
10
- type InferDomainEvent<EVENT extends DomainEvent<any, any>> = EVENT extends DomainBroadcastEvent<infer DATA> ? DomainBroadcastEvent<DATA> : EVENT extends DomainRequestEvent<infer DATA, infer CALLBACK> ? DomainRequestEvent<DATA, CALLBACK> : never;
10
+ type InferDomainEvent<EVENT extends DomainEvent<any, any>> = EVENT extends DomainBroadcastEvent<infer DATA> ? DomainBroadcastEvent<DATA> : EVENT extends DomainRequestEvent<infer DATA, infer REPLY_DATA> ? DomainRequestEvent<DATA, REPLY_DATA> : never;
11
11
  type InferDomainEventApi<EVENT extends DomainEvent<any, any>> = InferDomainEvent<EVENT>['api'];
12
12
  type CustomerStateRecords<T> = keyof T extends never ? {} : Record<string, object>;
13
13
  type CustomerCommandRecords<T> = keyof T extends never ? {} : Record<string, Function>;
@@ -1,9 +1 @@
1
- import { ComputedRef } from 'vue';
2
- export declare function createPromiseCallback<CALLBACK extends (...args: any[]) => Error | void>(callback: CALLBACK, finishOnError?: boolean, timeoutMs?: number | false): {
3
- promise: Promise<void>;
4
- callback: CALLBACK;
5
- onError: (e: Error) => void;
6
- resolved: ComputedRef<boolean>;
7
- error: ComputedRef<Error | undefined>;
8
- };
9
1
  export declare function genId(): string;
package/domain/event.d.ts CHANGED
@@ -1,33 +1,43 @@
1
- import { type DeepReadonly, type UnwrapNestedRefs, WatchHandle, ComputedRef, ShallowRef } from 'vue';
2
- export type DomainEventData = {
3
- [key: string]: any;
1
+ import { DeepReadonly, UnwrapNestedRefs } from 'vue';
2
+ export type DomainRequestEventOptions<DATA, ON_REPLY extends (data: any) => void> = {
3
+ dataType?: DATA;
4
+ onReply: ON_REPLY;
5
+ onError?: (e: Error) => void;
6
+ maxListenerCount?: number;
7
+ isTerminateOnError?: boolean;
8
+ timeoutMs?: number | false;
4
9
  };
5
- export type DomainRequestEventReply = (...args: any[]) => void | Error;
6
- export type DomainEvent<DATA extends DomainEventData, REPLY extends DomainRequestEventReply> = DomainRequestEvent<DATA, REPLY> | DomainBroadcastEvent<DATA>;
7
- export type DomainDestroyedEventApi = ReturnType<typeof createBroadcastEvent<{}>>['api'];
8
- export type DomainRequestEvent<DATA extends DomainEventData, REPLY extends DomainRequestEventReply> = {
9
- watchHandles: WatchHandle[];
10
- publishRequest: (data: UnwrapNestedRefs<DATA>) => Promise<void>;
10
+ export type DomainRequestEvent<DATA, REPLY_DATA> = {
11
+ listeners: DomainRequestEventListener<DATA, REPLY_DATA>[];
12
+ publishRequest: (data: DeepReadonly<UnwrapNestedRefs<DATA>>) => Promise<REPLY_DATA>;
11
13
  api: {
12
- latestVersion: ComputedRef<ShallowRef<string>>;
13
- watchPublishRequest: (cb: (event: {
14
- data: DeepReadonly<UnwrapNestedRefs<DATA>>;
15
- version: string;
16
- reply: REPLY;
17
- }) => void) => WatchHandle;
14
+ latestVersion: Readonly<string>;
15
+ listenAndReply: (replyFn: DomainRequestEventListener<DATA, REPLY_DATA>) => () => void;
18
16
  };
19
17
  };
20
- export type DomainBroadcastEvent<DATA extends DomainEventData> = {
21
- watchHandles: WatchHandle[];
22
- publish: (data: UnwrapNestedRefs<DATA>) => void;
18
+ export type DomainRequestEventListener<DATA, REPLY_DATA> = (param: {
19
+ data: DeepReadonly<UnwrapNestedRefs<DATA>>;
20
+ version: string;
21
+ }) => REPLY_DATA;
22
+ export type DomainBroadcastEvent<DATA> = {
23
+ listeners: DomainBroadcastEventListener<DATA>[];
24
+ publish: (data: DeepReadonly<UnwrapNestedRefs<DATA>>) => void;
23
25
  api: {
24
- latestVersion: ComputedRef<ShallowRef<string>>;
25
- watchPublish: (cb: (event: {
26
+ latestVersion: Readonly<string>;
27
+ listen: (cb: (event: {
26
28
  data: DeepReadonly<UnwrapNestedRefs<DATA>>;
27
29
  version: string;
28
- }) => void) => WatchHandle;
30
+ }) => void) => () => void;
29
31
  };
30
32
  };
31
- export declare function createRequestEvent<DATA extends DomainEventData, REPLY extends DomainRequestEventReply>(_: DATA, reply: REPLY, stopOnError?: boolean, timeoutMs?: number | false): DomainRequestEvent<DATA, REPLY>;
32
- export declare function createBroadcastEvent<DATA extends DomainEventData = never>(): DomainBroadcastEvent<DATA>;
33
- export declare function createBroadcastEvent<DATA extends DomainEventData>(_: DATA): DomainBroadcastEvent<DATA>;
33
+ export type DomainBroadcastEventListener<DATA> = (param: {
34
+ data: DeepReadonly<UnwrapNestedRefs<DATA>>;
35
+ version: string;
36
+ }) => void;
37
+ export type DomainDestroyedEventApi = DomainBroadcastEvent<{}>['api'];
38
+ export type DomainEvent<DATA, REPLY_DATA> = DomainRequestEvent<DATA, REPLY_DATA> | DomainBroadcastEvent<DATA>;
39
+ export declare function createRequestEvent<DATA extends object = {}>(_dataType?: DATA): {
40
+ options: <ON_REPLY extends (replyData: any) => void, REPLY_DATA = Parameters<ON_REPLY>[0]>(options: DomainRequestEventOptions<DATA, ON_REPLY>) => DomainRequestEvent<DATA, REPLY_DATA>;
41
+ };
42
+ export declare function createBroadcastEvent<DATA extends object = {}>(_?: DATA): DomainBroadcastEvent<DATA>;
43
+ export declare function largeNumberIncrease(num1: string): string;