UNPKG

1.01 kBTypeScriptView Raw
1/** @module config */
2import { ConfigParams } from './ConfigParams';
3/**
4 * An interface to set configuration parameters to an object.
5 *
6 * It can be added to any existing class by implementing a single <code>configure()</code> method.
7 *
8 * If you need to emphasis the fact that <code>configure()</code> method can be called multiple times
9 * to change object configuration in runtime, use [[IReconfigurable]] interface instead.
10 *
11 * @see [[ConfigParams]]
12 *
13 * ### Example ###
14 *
15 * export class MyClass implements IConfigurable {
16 * private _myParam: string = "default value";
17 *
18 * public configure(config: ConfigParams): void {
19 * this._myParam = config.getAsStringWithDefault("options.param", myParam);
20 * ...
21 * }
22 * }
23 */
24export interface IConfigurable {
25 /**
26 * Configures component by passing configuration parameters.
27 *
28 * @param config configuration parameters to be set.
29 */
30 configure(config: ConfigParams): void;
31}