From 79ab4a5adf2adcb06f34df81cdb35a00bbf2b83f Mon Sep 17 00:00:00 2001 From: Karl Shea Date: Sun, 29 Sep 2019 14:35:35 -0500 Subject: [PATCH] Chained request progress --- Source/Siesta/Request/RequestChaining.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Siesta/Request/RequestChaining.swift b/Source/Siesta/Request/RequestChaining.swift index 83b48e90..b4d9ddc4 100644 --- a/Source/Siesta/Request/RequestChaining.swift +++ b/Source/Siesta/Request/RequestChaining.swift @@ -79,7 +79,7 @@ public enum RequestChainAction case useThisResponse } -internal struct RequestChainDelgate: RequestDelegate +internal class RequestChainDelgate: RequestDelegate { typealias ActionCallback = (ResponseInfo) -> RequestChainAction @@ -87,6 +87,8 @@ internal struct RequestChainDelgate: RequestDelegate private let wrappedRequest: Request private let determineAction: ActionCallback + + private var nextRequestProgress: Double? init(wrapping request: Request, whenCompleted determineAction: @escaping ActionCallback) { @@ -126,10 +128,14 @@ internal struct RequestChainDelgate: RequestDelegate request.start() // Necessary if we are passing to deferred original request request.onCompletion { completionHandler.broadcastResponse($0) } + request.onProgress + { progress in self.nextRequestProgress = progress } } } - // TODO: progress reporting + func computeProgress() -> Double { + return nextRequestProgress ?? wrappedRequest.progress + } func repeated() -> RequestDelegate {