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:Default implementation, asynchronousactionType: content: ) Handles an async request to an Interactor, calling
Destinationable.handleAsyncInteractorResultto 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.InteractorTypeParameters
destinationThe Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.
contentAn optional content model used to make a request to the Interactor.
-
asyncRequest(destination:Default implementation, asynchronousactionType: content: ) 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.InteractorTypeParameters
destinationThe Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.
contentAn optional content model used to make a request to the Interactor.
Return Value
The Result of the Interactor request.
-
resolveAsyncRequest(destination:Default implementation, asynchronousactionType: content: resultTransformer: ) Bridges a caller’s type-erased
InteractorRequestActionTypeableinto this assistant’s concreteRequest.ActionType, calls the typedasyncRequest(destination:actionType:content:), and converts the result intoContentType.If the Interactor’s
Request.ResultDatatype differs fromContentType, supply aresultTransformerto 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 byAction/sequence steps, which get their transformer from anActionConfiguration) andDestinationable.performAction(for:content:)(which looks its transformer up by event type). Any caller that only has an erasedactionTyperather than this assistant’s concreteRequest.ActionTypeshould use this method instead of callingasyncRequestdirectly.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.InteractorTypeParameters
destinationThe Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.
actionTypeThe Interactor action type to request be performed.
contentOptional content to be used with the request.
resultTransformerAn optional, type-erased transformer that converts the Interactor’s raw result into
ContentType.Return Value
The Result of the Interactor request.
-
asyncRequestForAction(destination:Default implementation, asynchronousactionType: content: resultTransformer: ) Calls
resolveAsyncRequest(destination:actionType:content:resultTransformer:)with the givenresultTransformer.Actioncalls this method rather thanresolveAsyncRequestdirectly, sinceAction‘sresultTransformercomes from anActionConfigurationstep 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.InteractorTypeParameters
destinationThe Destination which the Interactor is associated with. This reference is used to make requests to the Interactor.
actionTypeThe Interactor action type to request be performed.
contentOptional content to be used with the request.
resultTransformerAn optional, type-erased transformer that converts the Interactor’s raw result into
ContentType.Return Value
The Result of the Interactor request.
-
requestMethodExtension methodDeclaration
Swift
@MainActor var requestMethod: InteractorRequestMethod { get } -
handleRequest(destination:Extension methodactionType: content: ) Declaration
Swift
@MainActor func handleRequest<Destination>(destination: Destination, actionType: Request.ActionType, content: ContentType?) where Destination : Destinationable, Self.InteractorType == Destination.InteractorType -
handleAsyncRequest(destination:Extension method, asynchronousactionType: content: ) Undocumented
Declaration
Swift
@MainActor func handleAsyncRequest<Destination>(destination: Destination, actionType: any InteractorRequestActionTypeable, content: ContentType?) async where Destination : Destinationable, Self.InteractorType == Destination.InteractorType
View on GitHub