HACachePopulateInfo

public struct HACachePopulateInfo<OutgoingType>

Information about the populate call in the cache

This is issued in a few situations:

  1. To initially populate the cache value for the first to-the-cache subscription
  2. To update the value when reconnecting after having been disconnected
  3. When a subscribe handler says that it needs to re-execute the populate to get a newer value
  • Create the information for populate

    Declaration

    Swift

    public init<IncomingType: HADataDecodable>(
        request: HATypedRequest<IncomingType>,
        transform: @escaping (HACacheTransformInfo<IncomingType, OutgoingType?>) -> OutgoingType
    )

    Parameters

    request

    The request to perform

    transform

    The handler to convert the request’s result into the cache’s value type

  • The untyped request that underlies the request that created this info

    Important

    This is intended to be used exclusively for writing tests; this method is not called by the cache.

    Declaration

    Swift

    public let request: HARequest
  • Error during transform attempt

    See more

    Declaration

    Swift

    public enum TransformError : Error
  • Attempt to replicate the transform provided during initialization

    Since we erase away the incoming type, you need to provide this hinted with a type when executing this block.

    Important

    This is intended to be used exclusively for writing tests; this method is not called by the cache.

    Throws

    If the type of incoming does not match the original IncomingType

    Declaration

    Swift

    public func transform<IncomingType>(incoming: IncomingType, current: OutgoingType?) throws -> OutgoingType

    Parameters

    incoming

    The incoming value, of some given type – intended to be the IncomingType that created this

    current

    The current value part of the transform info

    Return Value

    The transformed incoming value