ModuleFactory

public protocol ModuleFactory

A factory that is used to create a specific Module with some standard parameters.

  • The specific Module that this factory can create.

    Declaration

    Swift

    associatedtype SpecificModule : Module
  • Returns true if the module can be instantiated multiple times.

    Declaration

    Swift

    var allowsMultipleInstances: Bool { get }
  • The type of Module that this factory creates

    Declaration

    Swift

    var moduleType: String { get }
  • Creates a new Module if the received module configuration is correct for it’s initialization.

    Declaration

    Swift

    func create(moduleId: String, context: TealiumContext, moduleConfiguration: DataObject) -> SpecificModule?

    Parameters

    moduleId

    The ID for this specific instance of the module.

    context

    The TealiumContext shared by all modules.

    moduleConfiguration

    The DataObject configuration 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 implementation

    Returns 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 this Module.

    Default Implementation

    Declaration

    Swift

    func getEnforcedSettings() -> [DataObject]

    Return Value

    An array of DataObject representing the ModuleSettings, containing some of the settings used by the Module that will be enforced and remain constant during the life of this Module. Each DataObject in the Array will be used for the settings of one instance of the Module, 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 calling MultipleInstancesModuleSettingsBuilder.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, the ModuleFactory will not instantiate any Module by default. In this case modules will be instantiated only if they are configured in the local or remote settings.