ConfigurableModuleBuilder
Factory that lets you create configurable modules and provides a way to reduce the majority of dynamic module boilerplate.
class ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> {
constructor(options: ConfigurableModuleBuilderOptions = {}, parentBuilder?: ConfigurableModuleBuilder<ModuleOptions, "register", "create", {}>)
protected staticMethodKey: StaticMethodKey
protected factoryClassMethodKey: FactoryClassMethodKey
protected extras: ExtraModuleDefinitionOptions
protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule
protected logger: Logger
protected options: ConfigurableModuleBuilderOptions
setExtras<ExtraModuleDefinitionOptions>(extras: ExtraModuleDefinitionOptions, transformDefinition: (definition: DynamicModule, extras: ExtraModuleDefinitionOptions) => DynamicModule = def => def)
setClassMethodName<StaticMethodKey extends string>(key: StaticMethodKey)
setFactoryMethodName<FactoryClassMethodKey extends string>(key: FactoryClassMethodKey)
build(): ConfigurableModuleHost<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>
}
Constructor
Parameters
|
Properties
Property | Description |
---|---|
protected staticMethodKey: StaticMethodKey
|
|
protected factoryClassMethodKey: FactoryClassMethodKey
|
|
protected extras: ExtraModuleDefinitionOptions
|
|
protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule
|
|
protected logger: Logger
|
Read-only. |
protected options: ConfigurableModuleBuilderOptions
|
Read-only. Declared in constructor. |
Methods
setExtras() | |||||||||
---|---|---|---|---|---|---|---|---|---|
Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition). Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers). |
|||||||||
Parameters
Examples
|
|||||||||
This method also applies the so-called "module definition transform function" that takes the auto-generated dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters. The "extras" object consists of values explicitly specified by module consumers and default values. |
setClassMethodName() |
---|
Dynamic modules must expose public static methods that let you pass in configuration parameters (control the module's behavior from the outside). Some frequently used names that you may have seen in other modules are: "forRoot", "forFeature", "register", "configure". |
This method "setClassMethodName" lets you specify the name of the method that will be auto-generated. |
setFactoryMethodName() |
---|
Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule") let you pass the configuration factory class that will be registered and instantiated as a provider. This provider then will be used to retrieve the module's configuration. To provide the configuration, the corresponding factory method must be implemented. |
This method ("setFactoryMethodName") lets you control what method name will have to be implemented by the config factory (default is "create"). |
build() |
---|
Returns an object consisting of multiple properties that lets you easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details. |
ParametersThere are no parameters. Returns
|