MigratingStorage

extension MoEngageStorage.MigratingStorage: MoEngageStorage.ReadOnlyLocation
extension MoEngageStorage.MigratingStorage: MoEngageStorage.MigratableLocation
extension MoEngageStorage.MigratingStorage: MoEngageStorage.WriteOnlyLocation where ReadInput == Void
  • Reads from the primary location; consults the migration chain when needed.

    When a migration value is found it is saved to the primary location via try? (write-back failures are silently suppressed), and all traversed legacy locations are cleaned up. If the primary read fails, PrimaryReadError is rethrown directly to the caller.

    Throws

    PrimaryReadError when the primary read fails.

    Declaration

    Swift

    public func read(
        withInput input: ReadInput,
        fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(ReadError) -> Value

    Parameters

    input

    Unused (Void).

    sdkInstance

    The isolated SDK instance to read from.

    Return Value

    The stored value.

MigratableLocation

  • Removes the value from all chain entries, then from the primary location.

    Chain removals are silently suppressed via try?. Only the primary removal can surface an error. When primaryRemove is nil this is a no-op after chain clean-up.

    Throws

    PrimaryRemoveError when the primary removal fails.

    Declaration

    Swift

    public func remove(
        fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(RemoveError) -> RemoveOutput

    Parameters

    sdkInstance

    The isolated SDK instance to remove from.

Available where ReadInput == Void

  • Writes directly to the primary location.

    When primaryWrite is nil (primary has no write capability) this is a no-op.

    Throws

    PrimaryWriteError when the primary write fails.

    Declaration

    Swift

    public func write(
        _ value: Value,
        toInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(WriteError) -> WriteOutput

    Parameters

    value

    The value to persist.

    sdkInstance

    The isolated SDK instance to write to.