From 75c2b72f5767f8a364ca027e4b520e19e313d2b5 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Wed, 23 Sep 2020 08:46:21 +0200 Subject: [PATCH] Add Application.getComponent() --- src/Application.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Application.ts b/src/Application.ts index bfa586f..594dcda 100644 --- a/src/Application.ts +++ b/src/Application.ts @@ -207,7 +207,7 @@ export default abstract class Application { } } - async stop(): Promise { + public async stop(): Promise { 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>(type: Type): T | undefined { + return this.components.find(component => component.constructor === type); + } } \ No newline at end of file