更新了WBWatcher的一个写法
This commit is contained in:
parent
8023bc7e33
commit
f29a309f2f
|
|
@ -1,5 +1,6 @@
|
|||
import { SelectRowShape } from ".";
|
||||
import { Context } from "./Context";
|
||||
import { EntityDict, OperationResult, SelectionResult } from "./Entity";
|
||||
import { EntityDict, OperationResult } from "./Entity";
|
||||
declare type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
|
||||
export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
||||
name: string;
|
||||
|
|
@ -8,12 +9,12 @@ export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|||
action: ED[T]['Operation']['action'];
|
||||
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
||||
}
|
||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>, Proj extends ED[T]['Selection']['data'] = ED[T]['Selection']['data']> {
|
||||
name: string;
|
||||
entity: T;
|
||||
filter: ED[T]['Selection']['filter'] | (() => Promise<ED[T]['Selection']['filter']>);
|
||||
projection: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>);
|
||||
fn: (context: Cxt, data: SelectionResult<ED[T]['Schema'], Required<this['projection']>>['result']) => Promise<OperationResult<ED>>;
|
||||
projection: Proj | (() => Promise<Proj>);
|
||||
fn: (context: Cxt, data: SelectRowShape<ED[T]['Schema'], Proj>[]) => Promise<OperationResult<ED>>;
|
||||
}
|
||||
export declare type Watcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = BBWatcher<ED, T> | WBWatcher<ED, T, Cxt>;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { SelectRowShape } from ".";
|
||||
import { Context } from "./Context";
|
||||
import { DeduceFilter, DeduceRemoveOperationData, DeduceUpdateOperationData, EntityDict, OperationResult, SelectionResult } from "./Entity";
|
||||
|
||||
|
|
@ -11,12 +12,12 @@ export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|||
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
||||
};
|
||||
|
||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>, Proj extends ED[T]['Selection']['data'] = ED[T]['Selection']['data']> {
|
||||
name: string;
|
||||
entity: T;
|
||||
filter: ED[T]['Selection']['filter'] | (() => Promise<ED[T]['Selection']['filter']>);
|
||||
projection: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>);
|
||||
fn: (context: Cxt, data: SelectionResult<ED[T]['Schema'], Required<this['projection']>>['result']) => Promise<OperationResult<ED>>;
|
||||
projection: Proj | (() => Promise<Proj>);
|
||||
fn: (context: Cxt, data: SelectRowShape<ED[T]['Schema'], Proj>[]) => Promise<OperationResult<ED>>;
|
||||
};
|
||||
|
||||
export type Watcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = BBWatcher<ED, T> | WBWatcher<ED, T, Cxt>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue