feat: beforeSubAppLoad event
This commit is contained in:
		
							parent
							
								
									6b40c92d49
								
							
						
					
					
						commit
						542175f454
					
				@ -9,7 +9,12 @@ export interface registerAppOptions extends Transactionable {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ApplicationModel extends Model {
 | 
					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();
 | 
					    await app.load();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!(await app.isInstalled())) {
 | 
					    if (!(await app.isInstalled())) {
 | 
				
			||||||
@ -35,6 +40,7 @@ export class ApplicationModel extends Model {
 | 
				
			|||||||
    const app = mainApp.appManager.createApplication(appName, {
 | 
					    const app = mainApp.appManager.createApplication(appName, {
 | 
				
			||||||
      ...options.appOptionsFactory(appName, mainApp),
 | 
					      ...options.appOptionsFactory(appName, mainApp),
 | 
				
			||||||
      ...appOptions,
 | 
					      ...appOptions,
 | 
				
			||||||
 | 
					      name: appName,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const isInstalled = await (async () => {
 | 
					    const isInstalled = await (async () => {
 | 
				
			||||||
@ -52,7 +58,7 @@ export class ApplicationModel extends Model {
 | 
				
			|||||||
      await options.dbCreator(app);
 | 
					      await options.dbCreator(app);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await AppModel.handleAppStart(app, options);
 | 
					    await AppModel.handleAppStart(mainApp, app, options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await AppModel.update(
 | 
					    await AppModel.update(
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user