apploader增加了execRoutine方法

This commit is contained in:
Xu Chang 2023-05-15 11:51:24 +08:00
parent fc0a391638
commit a834e22c9a
3 changed files with 10 additions and 0 deletions

1
lib/AppLoader.d.ts vendored
View File

@ -21,4 +21,5 @@ export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt exten
getEndpoints(): Record<string, Endpoint<ED, Cxt>>;
startTimers(): void;
execStartRoutines(): Promise<void>;
execRoutine(routine: (context: Cxt) => Promise<void>): Promise<void>;
}

View File

@ -217,5 +217,9 @@ class AppLoader extends types_1.AppLoader {
}
}
}
async execRoutine(routine) {
const context = await this.contextBuilder()(this.dbStore);
await routine(context);
}
}
exports.AppLoader = AppLoader;

View File

@ -261,4 +261,9 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Async
}
}
}
async execRoutine(routine: (context: Cxt) => Promise<void>) {
const context = await this.contextBuilder()(this.dbStore);
await routine(context);
}
}