一些编译的问题,以及listNode在监听cache变化时的正确处理

This commit is contained in:
Xu Chang 2022-11-26 17:36:17 +08:00
parent d89cad87ca
commit 29ee116ffc
7 changed files with 11 additions and 14 deletions

View File

@ -39,7 +39,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
}>): Partial<ED[T]["Schema"]>[];
private getInner;
get<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, params?: SelectOption): Partial<ED[T]["Schema"]>[];
judgeRelation(entity: keyof ED, attr: string): string | 0 | 2 | 1 | string[];
judgeRelation(entity: keyof ED, attr: string): string | 0 | 1 | 2 | string[];
bindOnSync(callback: (opRecords: OpRecord<ED>[]) => void): void;
unbindOnSync(callback: (opRecords: OpRecord<ED>[]) => void): void;
getCachedData(): { [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; };

View File

@ -38,7 +38,7 @@ declare abstract class Node<ED extends EntityDict & BaseEntityDict, T extends ke
setExecuting(executing: boolean): void;
getParent(): SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, T, Cxt, FrontCxt, AD> | VirtualNode<ED, Cxt, FrontCxt, AD> | undefined;
protected getProjection(): ED[T]["Selection"]["data"];
protected judgeRelation(attr: string): string | 0 | 2 | 1 | string[];
protected judgeRelation(attr: string): string | 0 | 1 | 2 | string[];
protected contains(filter: ED[T]['Selection']['filter'], conditionalFilter: ED[T]['Selection']['filter']): boolean;
protected repel(filter1: ED[T]['Selection']['filter'], filter2: ED[T]['Selection']['filter']): boolean;
}

View File

@ -602,8 +602,7 @@ var ListNode = /** @class */ (function (_super) {
此时对userRelation的删除动作就会导致user不会被移出list
*/
if (needRefresh) {
// 这里因为operation还没被移除掉(execute还没有结束)所以同步的时候不能计算动态的operation产生的id
var _b = this.constructSelection(true, true), filter = _b.filter, sorter = _b.sorter;
var _b = this.constructSelection(true), filter = _b.filter, sorter = _b.sorter;
var result = this.cache.get(this.getEntity(), {
data: {
id: 1,

View File

@ -1,6 +1,5 @@
import { EntityDict, OperationResult, OpRecord, SelectOption } from 'oak-domain/lib/types/Entity';
import { StorageSchema } from "oak-domain/lib/types/Storage";
import { TriggerExecutor } from 'oak-domain/lib/store/TriggerExecutor';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { Checker, CheckerType, TxnOption } from 'oak-domain/lib/types';
import { TreeStore, TreeStoreOperateOption } from 'oak-memory-tree-store';

View File

@ -15,7 +15,7 @@ interface DebugStoreSelectOption extends TreeStoreSelectOption {
};
export class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> extends TreeStore<ED> implements AsyncRowStore<ED, Cxt> {
private executor: TriggerExecutor<ED, Cxt>;
private executor: TriggerExecutor<ED>;
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>) {
super(storageSchema);
this.executor = new TriggerExecutor((cxtString) => contextBuilder(cxtString)(this));
@ -32,11 +32,11 @@ export class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends Asyn
protected async cascadeUpdateAsync<T extends keyof ED, OP extends DebugStoreOperateOption>(entity: T, operation: ED[T]['Operation'], context: AsyncContext<ED>, option: OP) {
if (!option.blockTrigger) {
await this.executor.preOperation(entity, operation, context as any, option);
await this.executor.preOperation(entity, operation, context, option);
}
const result = await super.cascadeUpdateAsync(entity, operation, context, option);
if (!option.blockTrigger) {
await this.executor.postOperation(entity, operation, context as any, option);
await this.executor.postOperation(entity, operation, context, option);
}
return result;
}
@ -47,11 +47,11 @@ export class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends Asyn
}, selection) as ED[T]['Operation'];
if (!option.blockTrigger) {
await this.executor.preOperation(entity, selection2, context as any, option);
await this.executor.preOperation(entity, selection2, context, option);
}
const result = await super.cascadeSelectAsync(entity, selection2 as any, context, option);
const result = await super.cascadeSelectAsync(entity, selection2, context, option);
if (!option.blockTrigger) {
await this.executor.postOperation(entity, selection2, context as any, option, result);
await this.executor.postOperation(entity, selection2, context, option, result);
}
return result;
}

View File

@ -606,8 +606,7 @@ class ListNode<
userRelation的删除动作就会导致user不会被移出list
*/
if (needRefresh) {
// 这里因为operation还没被移除掉(execute还没有结束)所以同步的时候不能计算动态的operation产生的id
const { filter, sorter } = this.constructSelection(true, true);
const { filter, sorter } = this.constructSelection(true);
const result = this.cache.get(this.getEntity(), {
data: {
id: 1,

View File

@ -210,7 +210,7 @@ export function reRender<
if (Object.keys(data).length === 0) {
Object.assign(data, {
__now: Date.now(), // 如果没有任何state被set可能会不触发重渲染
})
});
}
this.setState(data);
}