ModuleFactory
public protocol ModuleFactory
A factory that is used to create a specific Module with some standard parameters.
-
Returns true if the module can be instantiated multiple times.
Declaration
Swift
var allowsMultipleInstances: Bool { get } -
The type of
Modulethat this factory createsDeclaration
Swift
var moduleType: String { get } -
Creates a new
Moduleif the received module configuration is correct for it’s initialization.Declaration
Swift
func create(moduleId: String, context: TealiumContext, moduleConfiguration: DataObject) -> SpecificModule?Parameters
moduleIdThe ID for this specific instance of the module.
contextThe
TealiumContextshared by all modules.moduleConfigurationThe
DataObjectconfiguration for this specific module, used to initialize it and potentially disable it if some mandatory settings are missing or invalid.Return Value
the newly created
Module, if the initialization succeeded, or nil. -
getEnforcedSettings()Default implementationReturns some optional settings for this module that override any other Local or Remote settings fields.
Only the values at the specific keys returned in this Dictionary will be enforced and remain constant during the life of this
Module. Other values at other keys that are not present in this Dictionary can be set by Local or Remote settings and be updated by future Remote settings refreshes during the life of thisModule.Default Implementation
Declaration
Swift
func getEnforcedSettings() -> [DataObject]Return Value
An array of
DataObjectrepresenting theModuleSettings, containing some of the settings used by theModulethat will be enforced and remain constant during the life of thisModule. EachDataObjectin the Array will be used for the settings of one instance of theModule, if this module allows to be initialized multiple times. Otherwise only the first one will be used. In case of multiple settings, be sure to provide a unique module ID by callingMultipleInstancesModuleSettingsBuilder.setModuleId(_:). If no module ID is provided, moduleType will be used instead. If two or more module IDs are the same, only the first settings object will be used by the caller; subsequent settings will be discarded. If this method returns an empty array, theModuleFactorywill not instantiate anyModuleby default. In this case modules will be instantiated only if they are configured in the local or remote settings.
View on GitHub