From efb9bad136d0b3916aa251c981f1536c2ff783f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 8 Oct 2020 11:34:59 +0200 Subject: [PATCH] MOBILE-3565 services: Fix init service linting --- src/app/services/init.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/services/init.ts b/src/app/services/init.ts index 5575b8b33..8e06292fc 100644 --- a/src/app/services/init.ts +++ b/src/app/services/init.ts @@ -14,7 +14,7 @@ import { Injectable } from '@angular/core'; -import { CoreUtils } from '@services/utils/utils'; +import { CoreUtils, PromiseDefer } from '@services/utils/utils'; import { CoreLogger } from '@singletons/logger'; import { makeSingleton } from '@singletons/core.singletons'; @@ -50,12 +50,13 @@ export type CoreInitHandler = { */ @Injectable() export class CoreInitDelegate { + static readonly DEFAULT_PRIORITY = 100; // Default priority for init processes. static readonly MAX_RECOMMENDED_PRIORITY = 600; - protected initProcesses = {}; + protected initProcesses: { [s: string]: CoreInitHandler } = {}; protected logger: CoreLogger; - protected readiness; + protected readiness: CoreInitReadinessPromiseDefer; constructor() { this.logger = CoreLogger.getInstance('CoreInitDelegate'); @@ -163,6 +164,14 @@ export class CoreInitDelegate { this.logger.log(`Registering process '${handler.name}'.`); this.initProcesses[handler.name] = handler; } + } export class CoreInit extends makeSingleton(CoreInitDelegate) {} + +/** + * Deferred promise for init readiness. + */ +type CoreInitReadinessPromiseDefer = PromiseDefer & { + resolved?: boolean; // If true, readiness have been resolved. +};