/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { inject, InjectionToken } from '@angular/core';
import { CoreConfig } from './core-config';
import { CoreConfigurationLoaderService } from './core-configuration-loader.service';

/**
 * Injection token to get the loaded configuration.
 * Important: This must not be used in the AppModule, as this will result in the configuration always being null.
 * Background: The injection token's factory must be resolved after the APP_INITIALIZERs.
 */
export const CORE_CONFIG = new InjectionToken<CoreConfig>('CORE_CONFIG', {
  // cannot use CoreConfigurationService here due to async execution
  factory: () => inject(CoreConfigurationLoaderService).loadedConfig,
  providedIn: 'root',
});
