-
Notifications
You must be signed in to change notification settings - Fork 2
English__Data Sources__Single Value
The Single Value data source is just a specialization of the Dictionary
data source. This data source accepts a key and a value, and internally creates a dictionary object with a single
property (the provided key and value).
As with all other data sources, there is a specialized addSingleValue() method in the configuration builder that
assists with this job. This function is defined with two overloads:
addSingleValue<NewT extends Record<string, any>>(
path: string,
value?: ConfigurationValue,
hierarchySeparator?: string
): IBuilder<MergeResult<T, NewT>>;
addSingleValue<NewT extends Record<string, any>>(
dataFn: () => Promise<[string, ConfigurationValue]>,
hierarchySeparator?: string
): IBuilder<MergeResult<T, NewT>>;For both overloads, the last parameter (hierarchySeparator) is used to specify the string used inside the key to
define the hierarchy of the value.
For the first overload, the first two parameters are used to collect the key and the value, respectively.
For the second overload, the developer provides a function that, once executed, returns a two-value tuple (an array with two elements) where the first value is the key, and the second one is the value. This function approach is the recommended approach when doing any form of conditional configuration if obtaining the key or value will incur in potentially-wasted CPU cycles or RAM.
Since this is a specialization of the Dictionary data source, all of the data requirements of this ancestor apply
here too. Furthermore:
- The key is mandatory.
- The value must be a scalar (leaf) value.
- Filtering cannot be specified. No prefix or predicate function can be specified.
Contents
- English
- Theory
- JavaScript Concepts
- Data Sources
- Español
- Teoría