Add Application.getComponent()

This commit is contained in:
Alice Gaudon 2020-09-23 08:46:21 +02:00
parent c1114c83b8
commit 75c2b72f57
1 changed files with 5 additions and 1 deletions

View File

@ -207,7 +207,7 @@ export default abstract class Application {
}
}
async stop(): Promise<void> {
public async stop(): Promise<void> {
Logger.info('Stopping application...');
for (const component of this.components) {
@ -254,4 +254,8 @@ export default abstract class Application {
public getCache(): CacheProvider | undefined {
return this.cacheProvider;
}
public getComponent<T extends ApplicationComponent<any>>(type: Type<T>): T | undefined {
return <T>this.components.find(component => component.constructor === type);
}
}