MOBILE-3947 core: Fix null injection token

main
Noel De Martin 2023-12-04 16:59:08 +01:00
parent 76beb12d17
commit 48ebe85b51
2 changed files with 9 additions and 1 deletions

View File

@ -14,8 +14,15 @@
import envJson from '@/assets/env.json';
import { EnvironmentConfig } from '@/types/config';
import { InjectionToken } from '@angular/core';
import { CoreBrowser } from '@singletons/browser';
/**
* Injection token used for dependencies marked as optional that will never
* be resolved by Angular injectors.
*/
export const NULL_INJECTION_TOKEN = new InjectionToken('null');
/**
* Context levels enumeration.
*/

View File

@ -24,6 +24,7 @@ import { SQLiteDB } from '@classes/sqlitedb';
import { APP_SCHEMA, CoreStorageRecord, TABLE_NAME } from './database/storage';
import { CoreSites } from './sites';
import { CoreSite } from '@classes/sites/site';
import { NULL_INJECTION_TOKEN } from '@/core/constants';
/**
* Service to store data using key-value pairs.
@ -38,7 +39,7 @@ export class CoreStorageService {
table: AsyncInstance<CoreStorageTable>;
constructor(@Optional() @Inject(null) lazyTableConstructor?: () => Promise<CoreStorageTable>) {
constructor(@Optional() @Inject(NULL_INJECTION_TOKEN) lazyTableConstructor?: () => Promise<CoreStorageTable>) {
this.table = asyncInstance(lazyTableConstructor);
}