MirroredStorage
extension MoEngageStorage.MirroredStorage: MoEngageStorage.ReadOnlyLocation
where
Primary: MoEngageStorage.ReadOnlyLocation & MoEngageStorage.WriteOnlyLocation,
Mirror: MoEngageStorage.ReadOnlyLocation & MoEngageStorage.WriteOnlyLocation,
Primary.Input == Mirror.Input,
PrimaryStored == Primary.Stored,
MirrorStored == Mirror.Stored,
Primary.Stored == Mirror.Stored,
Primary.Stored == Primary.Saved,
Mirror.Stored == Mirror.Saved
extension MoEngageStorage.MirroredStorage: MoEngageStorage.WriteOnlyLocation
where
Primary: MoEngageStorage.WriteOnlyLocation,
Mirror: MoEngageStorage.WriteOnlyLocation,
Primary.Saved == Mirror.Saved,
Primary.Output == Mirror.Output,
Primary.Output == Void
extension MoEngageStorage.MirroredStorage: MoEngageStorage.MigratableLocation
where
Primary: MoEngageStorage.MigratableLocation,
Mirror: MoEngageStorage.MigratableLocation
Available where Primary: MoEngageStorage.ReadOnlyLocation & MoEngageStorage.WriteOnlyLocation, Mirror: MoEngageStorage.ReadOnlyLocation & MoEngageStorage.WriteOnlyLocation, Primary.Input == Mirror.Input, PrimaryStored == Primary.Stored, MirrorStored == Mirror.Stored, Primary.Stored == Mirror.Stored, Primary.Stored == Primary.Saved, Mirror.Stored == Mirror.Saved
-
Reads and synchronises the primary and mirror locations.
- From an extension: reads from the
mirrorlocation only, wrapping any error inOperationError/mirror(_:). - Without an app group: reads from the
primarylocation only, wrapping any error inOperationError/primary(_:). With an app group: reads both locations, wrapping errors as
OperationError/primary(_:)orOperationError/mirror(_:)respectively; reconciles viareconcileand writes the result back to both (write-back failures are silently suppressed).
Throws
OperationErroridentifying which location failed.Declaration
Swift
public func read( withInput input: Primary.Input, fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation ) throws(ReadError) -> Primary.StoredParameters
inputUnused (
Void).sdkInstanceThe isolated SDK instance providing context.
Return Value
The reconciled stored value.
- From an extension: reads from the
-
Writes the value to both locations according to the current process context.
Operations are attempted sequentially; the first failure is thrown immediately and the remaining write (if any) is not attempted:
primaryis written first when not running inside an extension; failure is wrapped inOperationError/primary(_:)and rethrown.mirroris written when anappGroupIDis configured; failure is wrapped inOperationError/mirror(_:)and rethrown.
Throws
OperationErroridentifying which location failed.Declaration
Swift
public func write( _ value: Primary.Saved, toInstance sdkInstance: isolated MoEngageSDKInstance = #isolation ) throws(WriteError)Parameters
valueThe value to persist.
sdkInstanceThe isolated SDK instance to write to.
-
Removes the value from both locations according to the current process context.
Operations are attempted sequentially; the first failure is thrown immediately and the remaining removal (if any) is not attempted:
primaryis removed first when not running inside an extension; failure is wrapped inOperationError/primary(_:)and rethrown.mirroris removed when anappGroupIDis configured; failure is wrapped inOperationError/mirror(_:)and rethrown.
Throws
OperationErroridentifying which location failed.Declaration
Swift
public func remove( fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation ) throws(RemoveError)Parameters
sdkInstanceThe isolated SDK instance to remove from.