AsyncInteractorAssisting

@MainActor
public protocol AsyncInteractorAssisting<InteractorType, ContentType> : InteractorAssisting

This protocol represents an assistant which helps a Destination make requests of an Interactor which participates in async/await flows. Concrete assistants conforming to this protocol should handle requests for a specific Interactor type.

  • handleAsyncRequest(destination:actionType:content:) Default implementation, asynchronous

    Handles an async request to an Interactor, calling Destinationable.handleAsyncInteractorResult to return the result of the operation.

    Default Implementation

    Declaration

    Swift

    @MainActor
    func handleAsyncRequest<Destination>(destination: Destination, actionType: Request.ActionType, content: ContentType?) async where Destination : Destinationable, Self.InteractorType == Destination.InteractorType

    Parameters

    destination

    The Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.

    content

    An optional content model used to make a request to the Interactor.

  • asyncRequest(destination:actionType:content:) Default implementation, asynchronous

    Handles a request to an Interactor in an asychronous context.

    Default Implementation

    Declaration

    Swift

    @MainActor
    func asyncRequest<Destination>(destination: Destination, actionType: Request.ActionType, content: ContentType?) async -> Result<Request.ResultData, any Error> where Destination : InteractorResultHandling, Self.InteractorType == Destination.InteractorType

    Parameters

    destination

    The Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.

    content

    An optional content model used to make a request to the Interactor.

    Return Value

    The Result of the Interactor request.

  • Bridges a caller’s type-erased InteractorRequestActionTypeable into this assistant’s concrete Request.ActionType, calls the typed asyncRequest(destination:actionType:content:), and converts the result into ContentType.

    If the Interactor’s Request.ResultData type differs from ContentType, supply a resultTransformer to bridge between the two. When no transformer is supplied, this falls back to a direct cast, which succeeds for the common case where the two types are the same.

    This is the shared primitive used by both asyncRequestForAction(destination:actionType:content:resultTransformer:) (used by Action/sequence steps, which get their transformer from an ActionConfiguration) and Destinationable.performAction(for:content:) (which looks its transformer up by event type). Any caller that only has an erased actionType rather than this assistant’s concrete Request.ActionType should use this method instead of calling asyncRequest directly.

    Default Implementation

    Declaration

    Swift

    @MainActor
    func resolveAsyncRequest<Destination>(destination: Destination, actionType: any InteractorRequestActionTypeable, content: ContentType?, resultTransformer: ContentTransformerWrapper<ContentType>?) async -> Result<ContentType, any Error> where Destination : InteractorResultHandling, Self.InteractorType == Destination.InteractorType

    Parameters

    destination

    The Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.

    actionType

    The Interactor action type to request be performed.

    content

    Optional content to be used with the request.

    resultTransformer

    An optional, type-erased transformer that converts the Interactor’s raw result into ContentType.

    Return Value

    The Result of the Interactor request.

  • Calls resolveAsyncRequest(destination:actionType:content:resultTransformer:) with the given resultTransformer. Action calls this method rather than resolveAsyncRequest directly, since Action‘s resultTransformer comes from an ActionConfiguration step rather than a per-event-type lookup.

    Default Implementation

    Declaration

    Swift

    @MainActor
    func asyncRequestForAction<Destination>(destination: Destination, actionType: any InteractorRequestActionTypeable, content: ContentType?, resultTransformer: ContentTransformerWrapper<ContentType>?) async -> Result<ContentType, any Error> where Destination : InteractorResultHandling, Self.InteractorType == Destination.InteractorType

    Parameters

    destination

    The Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.

    actionType

    The Interactor action type to request be performed.

    content

    Optional content to be used with the request.

    resultTransformer

    An optional, type-erased transformer that converts the Interactor’s raw result into ContentType.

    Return Value

    The Result of the Interactor request.

  • requestMethod Extension method

    Declaration

    Swift

    @MainActor
    var requestMethod: InteractorRequestMethod { get }
  • Declaration

    Swift

    @MainActor
    func handleRequest<Destination>(destination: Destination, actionType: Request.ActionType, content: ContentType?) where Destination : Destinationable, Self.InteractorType == Destination.InteractorType
  • Undocumented

    Declaration

    Swift

    @MainActor
    func handleAsyncRequest<Destination>(destination: Destination, actionType: any InteractorRequestActionTypeable, content: ContentType?) async where Destination : Destinationable, Self.InteractorType == Destination.InteractorType