Abstract
Config loader abstraction
./config-loader-test.ts
import { init } from '@biorate/inversion';import { ConfigLoader } from '../../src';import { key, value } from './';export class ConfigLoaderTest extends ConfigLoader { @init() protected initialize() { this.config.set(key, value); }} Copy
import { init } from '@biorate/inversion';import { ConfigLoader } from '../../src';import { key, value } from './';export class ConfigLoaderTest extends ConfigLoader { @init() protected initialize() { this.config.set(key, value); }}
./index.ts
import { inject, container, Types, Core } from '@biorate/inversion';import { IConfig, Config } from '@biorate/config';import { ConfigLoader } from '@biorate/config-loader';import { ConfigLoaderTest } from './config-loader-test';class Root extends Core() { @inject(Types.Config) public config: IConfig; @inject(Types.ConfigLoaderTest) public configLoaderTest: ConfigLoader;}container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();container.bind<ConfigLoader>(Types.ConfigLoaderTest).to(ConfigLoaderTest).inSingletonScope();container.bind<Root>(Root).toSelf().inSingletonScope();container.get<IConfig>(Types.Config).merge({});(async () => { const root = container.get<Root>(Root); await root.$run(); root.config.get('test'); // Hello world!})(); Copy
import { inject, container, Types, Core } from '@biorate/inversion';import { IConfig, Config } from '@biorate/config';import { ConfigLoader } from '@biorate/config-loader';import { ConfigLoaderTest } from './config-loader-test';class Root extends Core() { @inject(Types.Config) public config: IConfig; @inject(Types.ConfigLoaderTest) public configLoaderTest: ConfigLoader;}container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();container.bind<ConfigLoader>(Types.ConfigLoaderTest).to(ConfigLoaderTest).inSingletonScope();container.bind<Root>(Root).toSelf().inSingletonScope();container.get<IConfig>(Types.Config).merge({});(async () => { const root = container.get<Root>(Root); await root.$run(); root.config.get('test'); // Hello world!})();
Protected
Readonly
Config dependency
Initialize
Generated using TypeDoc
Description
Config loader abstraction
Features:
Example
./config-loader-test.ts
Example
./index.ts