TealiumInstanceManager
public class TealiumInstanceManager
A class that creates and stores all the created Tealium instances and reuses all of its dependencies
when a new instance is created with the same account and profile.
All references to created Tealium instances are kept strong, so an instance stays alive until it is
explicitly shut down via Tealium.shutdown() or TealiumInstanceManager.shutdown(_:). Dropping the
reference returned by create(config:completion:) does not deallocate the instance.
-
The shared
TealiumInstanceManagerobject.Declaration
Swift
public static let shared: TealiumInstanceManager -
Creates a new
Tealiuminstance based on the providedconfig.Typical usage in an app would keep the returned instance alive for as long as the app is alive. However, the instance is retained by the manager regardless, so it will stay alive until it is explicitly shut down via
Tealium.shutdown()orshutdown(_:).Calling this method with a
configwhoseTealiumConfig.keymatches an already created instance returns a newTealiumthat shares the same underlying implementation.Important
Hold onto the returned
Tealiuminstance for as long as you need it. Calling this method again with the sameaccount/profilecombination is supported, but each duplicate call allocates a small amount of internal state (a subject/subscription pair) that lives untilshutdown(). Prefer storing and reusing the original return value instead.Declaration
Swift
public func create(config: TealiumConfig, completion: ((InitializationResult<Tealium>) -> Void)? = nil) -> TealiumParameters
configThe required configuration options for this instance.
completionThe callback allows the caller to be notified once the instance is ready, or has failed during initialization alongside the cause of the failure.
Return Value
The
Tealiuminstance ready to accept input, although if the initialization fails, any method calls made to this object will also fail. -
Shuts down the given
Tealiuminstance.After calling this method, no further input will be processed and future method calls to the instance will fail with
TealiumError.instanceShutdown.Declaration
Swift
public func shutdown(_ tealium: Tealium)Parameters
tealiumThe
Tealiuminstance to shut down. -
Shuts down the
Tealiuminstance identified by the givenkey.After calling this method, no further input will be processed and future method calls to the instance will fail with
TealiumError.instanceShutdown.Declaration
Swift
public func shutdown(_ key: String)Parameters
keyThe key that identifies the
Tealiuminstance, as provided byTealiumConfig.key. -
Retrieves an existing
Tealiuminstance, if one has already been created using itsTealiumConfig.keyand has not been shut down.Declaration
Swift
public func get(_ config: TealiumConfig, completion: @escaping (Tealium?) -> Void)Parameters
configThe config that was used to create the instance.
completionThe block to receive the
Tealiuminstance on, if found. -
Retrieves an existing
Tealiuminstance, if one has already been created using itsTealiumConfig.keyand has not been shut down.Declaration
Swift
public func get(_ key: String, completion: @escaping (Tealium?) -> Void)
View on GitHub