feat: beforeSubAppLoad event

This commit is contained in:
ChengLei Shao 2023-02-16 01:46:23 +00:00
parent 6b40c92d49
commit 542175f454

View File

@ -9,7 +9,12 @@ export interface registerAppOptions extends Transactionable {
}
export class ApplicationModel extends Model {
static async handleAppStart(app: Application, options: registerAppOptions) {
static async handleAppStart(mainApp: Application, app: Application, options: registerAppOptions) {
await mainApp.emit('beforeSubAppLoad', {
mainApp,
subApp: app,
});
await app.load();
if (!(await app.isInstalled())) {
@ -35,6 +40,7 @@ export class ApplicationModel extends Model {
const app = mainApp.appManager.createApplication(appName, {
...options.appOptionsFactory(appName, mainApp),
...appOptions,
name: appName,
});
const isInstalled = await (async () => {
@ -52,7 +58,7 @@ export class ApplicationModel extends Model {
await options.dbCreator(app);
}
await AppModel.handleAppStart(app, options);
await AppModel.handleAppStart(mainApp, app, options);
await AppModel.update(
{