ProxyCompletionRequirement

public class ProxyCompletionRequirement<T> : CompletionRequirement<T>

A ProxyCompletionRequirement allows you to provide a completion requirement that adds some custom completion logic to an existing completion instance, and then return a possibly modified result value to the original requirement.

This mechanism allows your code to not care whether the completion you are proxying is called synchronously or not. Normally you need to know if completion you are wrapping would be called async or not, as you would need to capture the async completion status before defining your completion block so it can call completed on the async result.

This is a bit nasty in the nuance of the implementation. We may remove this if addProxyCompletionHandler

  • Undocumented

    Declaration

    Swift

    public init(proxying originalCompletion: CompletionRequirement<T>, proxyCompletionHandler: @escaping ProxyHandler)
  • The proxy must indicate that the original completion will complete async, but we return our own proxy async status object because we need to inject our own completion handling logic to possibly mutate the value.

    Declaration

    Swift

    override public func willCompleteAsync() -> DeferredStatus
  • The proxy calls its own completedAsync in order to execute the custom value modification logic, and that will in fact call the original completion’s completedSync.

    Declaration

    Swift

    override public func completedSync(_ result: T) -> SyncCompletionStatus