UNPKG

vulcain-corejs

Version:
60 lines (59 loc) 2.67 kB
import { DynamicPropertiesUpdater } from '../dynamicPropertiesUpdater'; import { PropertiesFactory } from './propertiesFactory'; import { DynamicProperty } from './dynamicProperty'; import { IDynamicProperty } from '../dynamicProperty'; import { ConfigurationSourceBuilder } from "../configurationSources/configurationSourceBuilder"; import { ConfigurationSource } from "../configurationSources/configurationSource"; import * as rx from 'rx'; /** * * Provides dynamic properties updated when config change. * Accessing a dynamic property is very fast. The last value is cached and updated on the fly * from a <b>ConfigurationSource</b> at fixed interval. * Updates are made using polling requests on a list of sources. * <p> * Dynamic properties are read only. You can set a value but it will be valid only as a default value. * </p> * <code> * let i:number = DynamicProperties.instance.getProperty("prop1"); * let i2:number = DynamicProperties.instance.getOrDefaultProperty("prop1", 1); * </code> */ export declare class DynamicProperties implements DynamicPropertiesUpdater { private _propertyChanged; readonly propertyChanged: rx.Observable<IDynamicProperty<any>>; private static _instance; private _configurationManager; private _properties; private _factory; /** * for test only */ static readonly factory: PropertiesFactory; static readonly instance: DynamicProperties; static init(pollingIntervalInSeconds?: number, sourceTimeoutInMs?: number): ConfigurationSourceBuilder; addProperty(name: string, prop: IDynamicProperty<any>): void; /** * Private constructor * <param name="pollingIntervalInSeconds"></param> * <param name="sourceTimeoutInMs"></param> */ constructor(pollingIntervalInSeconds?: number, sourceTimeoutInMs?: number); static registerPropertyAsDependency(name: string, defaultValue: any): void; /** /// Reset configuration and properties. /// All current properties will be invalid and all current sources will be lost. /// </summary> /// <param name="pollingIntervalInSeconds"></param> /// <param name="sourceTimeoutInMs"></param> */ reset(pollingIntervalInSeconds?: number, sourceTimeoutInMs?: number): void; readonly pollingIntervalInSeconds: number; onPropertyChanged(property: any, action: string): void; startPollingAsync(source?: ConfigurationSource): Promise<void>; getProperty(name: string): IDynamicProperty<any>; clear(): void; Updater_getOrCreate(name: string, factory: () => DynamicProperty<any>): IDynamicProperty<any>; Updater_removeProperty(name: string): void; dispose(): void; }