-
Notifications
You must be signed in to change notification settings - Fork 2
English__Data Sources__Object
wj-config
provides the Object
data source that allows the developer to directly provide an object as configuration
data source.
Despite being the simplest of data sources, is one of the most popular ones. It is by far the easiest one to use.
As with all other data sources, there is a specialized addObject()
method in the configuration builder that assists
with this job. This function defines one parameter in the form of 1 overload:
addObject<NewT extends Record<string, any>>(obj: NewT | (() => Promise<NewT>)): IBuilder<MergeResult<T, NewT>>;
- The object to use as configuration data source, or a function that returns said object.
Just like other data sources, the main data argument may be passed directly, or a function that returns it may be used as well. This function approach is the recommended approach when doing any form of conditional configuration if obtaining the object will incur in potentially-wasted CPU cycles or RAM.
This data source provides the most flexibility for developers. The object can be the product of any algorithm. For example, it can be used to include objects that are the result of reading files.
To be perfectly honest, this is the only truly needed data source. All other data sources are just convenient data
sources that provide shortcuts for popular tasks like JSON parsing or data fetching. Ok, granted, maybe the
Dictionary
data source is the one other "must-have" data source.
The only requirement is that the provided object be a POJO-like object.
Contents
- English
- Theory
- JavaScript Concepts
- Data Sources
- Español
- Teoría