HACacheSubscribeInfo

public struct HACacheSubscribeInfo<OutgoingType>

Information about the subscriptions used to keep the cache up-to-date

  • The response to a subscription event

    See more

    Declaration

    Swift

    public enum Response
    extension HACacheSubscribeInfo.Response: Equatable where OutgoingType: Equatable
  • Create the information for subscription

    Declaration

    Swift

    public init<IncomingType: HADataDecodable>(
        subscription: HATypedSubscription<IncomingType>,
        transform: @escaping (HACacheTransformInfo<IncomingType, OutgoingType>) -> Response
    )

    Parameters

    subscription

    The subscription to perform after populate completes

    transform

    The handler to convert the subscription’s handler type into the cache’s value

  • The untyped request that underlies the subscription 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,
        subscriptionPhase: HACacheSubscriptionPhase
    ) throws -> Response

    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

    subscriptionPhase

    The phase in which the subscription is, initial iteration or subsequent

    Return Value

    The response from the transform block