From 1c21a67b1ec475de85c28872f7d6f0199a7e5112 Mon Sep 17 00:00:00 2001 From: Ashli Rankin Date: Mon, 20 May 2024 15:34:32 -0400 Subject: [PATCH 1/2] Allows user to explicitly set the scheduler --- Sources/Networking/NetworkRequestStateController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Networking/NetworkRequestStateController.swift b/Sources/Networking/NetworkRequestStateController.swift index 15c5beb..16c2e08 100644 --- a/Sources/Networking/NetworkRequestStateController.swift +++ b/Sources/Networking/NetworkRequestStateController.swift @@ -94,13 +94,15 @@ public final class NetworkRequestStateController { /// - Parameters: /// - request: The request to send. /// - requestBehaviors: Additional behaviors to append to the request. - public func send(request: any NetworkRequest, requestBehaviors: [RequestBehavior] = [], retryCount: Int = 2) { + /// - retryCount: The number of times the action can be retried. + /// - scheduler: The scheduler to receive the call on. The default value is `DispatchQueue.main`. + public func send(request: any NetworkRequest, requestBehaviors: [RequestBehavior] = [], retryCount: Int = 2, scheduler: some Scheduler = DispatchQueue.main) { requestStatePublisher.send(.inProgress) requestPerformer.send(request, requestBehaviors: requestBehaviors) .retry(retryCount) .mapAsResult() - .receive(on: DispatchQueue.main) + .receive(on: scheduler) .sink(receiveValue: { [requestStatePublisher] result in requestStatePublisher.send(.completed(result)) }) From 457945424c1f4dc107d3572dac406bc0f2cbdd94 Mon Sep 17 00:00:00 2001 From: Ashli Rankin Date: Mon, 20 May 2024 15:55:07 -0400 Subject: [PATCH 2/2] Updated property position --- Sources/Networking/NetworkRequestStateController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Networking/NetworkRequestStateController.swift b/Sources/Networking/NetworkRequestStateController.swift index 16c2e08..9a61fad 100644 --- a/Sources/Networking/NetworkRequestStateController.swift +++ b/Sources/Networking/NetworkRequestStateController.swift @@ -93,10 +93,10 @@ public final class NetworkRequestStateController { /// Sends a request with the specified parameters. /// - Parameters: /// - request: The request to send. + /// - scheduler: The scheduler to receive the call on. The default value is `DispatchQueue.main`. /// - requestBehaviors: Additional behaviors to append to the request. /// - retryCount: The number of times the action can be retried. - /// - scheduler: The scheduler to receive the call on. The default value is `DispatchQueue.main`. - public func send(request: any NetworkRequest, requestBehaviors: [RequestBehavior] = [], retryCount: Int = 2, scheduler: some Scheduler = DispatchQueue.main) { + public func send(request: any NetworkRequest, scheduler: some Scheduler = DispatchQueue.main, requestBehaviors: [RequestBehavior] = [], retryCount: Int = 2) { requestStatePublisher.send(.inProgress) requestPerformer.send(request, requestBehaviors: requestBehaviors)