From 3939763d76d7c76201fd97efaee9935d0aa415ae Mon Sep 17 00:00:00 2001 From: Jack Stone Date: Fri, 20 Sep 2024 15:01:06 +0100 Subject: [PATCH] Remove unneeded spacing (#16) --- .../Publisher+AsInfallible.swift | 3 --- .../Publisher+AsObservable.swift | 6 ++--- .../BridgeBufferingStrategy.swift | 7 +++--- .../InfallibleBridgeBufferingStrategy.swift | 5 ++-- .../InfallibleType+AsPublisher.swift | 2 -- .../ObservableType+AsPublisher.swift | 6 ++--- ...ridgeBufferDoesNotOverflowIfPossible.swift | 6 ++--- .../InfallibleTypeBridgePublisher.swift | 1 - .../ObservableTypeBridgePublisher.swift | 1 - .../BridgeSubscription+Witness.swift | 24 +++++++++---------- .../Subscriptions/BridgeSubscription.swift | 1 - 11 files changed, 22 insertions(+), 40 deletions(-) diff --git a/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsInfallible.swift b/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsInfallible.swift index 6e228dd..0eadea0 100644 --- a/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsInfallible.swift +++ b/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsInfallible.swift @@ -7,7 +7,6 @@ import Combine import RxSwift extension Publisher where Failure == Never { - /// A bridging function that transforms a Combine `Publisher` into an RxSwift `Infallible`. /// /// This is a direct transformation when the `Failure` type is already `Never`. @@ -16,7 +15,6 @@ extension Publisher where Failure == Never { /// public func asInfallible() -> Infallible { return .create { observer -> Disposable in - let cancellable = sink( receiveCompletion: { _ in observer(.completed) }, receiveValue: { observer(.next($0)) } @@ -30,7 +28,6 @@ extension Publisher where Failure == Never { } extension Publisher { - /// A bridging function that transforms a Combine `Publisher` into an RxSwift `Infallible`. /// /// If any error is encountered, the provided `element` is returned. diff --git a/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsObservable.swift b/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsObservable.swift index 80d1f3c..7c0c5ff 100644 --- a/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsObservable.swift +++ b/Sources/CombineRx/Interoperability/Combine to RxSwift/Publisher+AsObservable.swift @@ -7,19 +7,17 @@ import Combine import RxSwift extension Publisher { - /// A bridging function that transforms a Combine `Publisher` into an RxSwift `Observable`. /// /// - Returns: An RxSwift `Observable` that is the bridged transformation of the given `Publisher`. /// public func asObservable() -> Observable { return .create { observer -> Disposable in - let cancellable = sink( receiveCompletion: { completion in switch completion { - case .finished: observer.onCompleted() - case .failure(let error): observer.onError(error) + case .finished: observer.onCompleted() + case .failure(let error): observer.onError(error) } }, receiveValue: { observer.onNext($0) } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/BridgeBufferingStrategy.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/BridgeBufferingStrategy.swift index 4b2ac55..a2af3c8 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/BridgeBufferingStrategy.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/BridgeBufferingStrategy.swift @@ -12,12 +12,11 @@ public enum BridgeBufferingStrategy { } extension BridgeBufferingStrategy { - var strategy: Publishers.BufferingStrategy { switch self { - case .error: return .customError { .bufferOverflow } - case .dropNewest: return .dropNewest - case .dropOldest: return .dropOldest + case .error: return .customError { .bufferOverflow } + case .dropNewest: return .dropNewest + case .dropOldest: return .dropOldest } } } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleBridgeBufferingStrategy.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleBridgeBufferingStrategy.swift index da7f8b1..945ee0e 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleBridgeBufferingStrategy.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleBridgeBufferingStrategy.swift @@ -11,11 +11,10 @@ public enum InfallibleBridgeBufferingStrategy { } extension InfallibleBridgeBufferingStrategy { - var strategy: Publishers.BufferingStrategy { switch self { - case .dropNewest: return .dropNewest - case .dropOldest: return .dropOldest + case .dropNewest: return .dropNewest + case .dropOldest: return .dropOldest } } } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleType+AsPublisher.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleType+AsPublisher.swift index 869e8ac..2ded347 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleType+AsPublisher.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/InfallibleType+AsPublisher.swift @@ -7,7 +7,6 @@ import Combine import RxSwift extension InfallibleType { - /// A bridging function that transforms an RxSwift `InfallibleType` into a Combine `Publisher`. /// /// There is a fundamental difference between Combine and RxSwift around the concept of back pressure and how it is handled. @@ -26,7 +25,6 @@ extension InfallibleType { withBufferSize size: Int, andBridgeBufferingStrategy whenFull: InfallibleBridgeBufferingStrategy ) -> Publishers.Buffer> { - return InfallibleTypeBridgePublisher(upstream: self) .buffer(size: size, prefetch: .byRequest, whenFull: whenFull.strategy) } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/ObservableType+AsPublisher.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/ObservableType+AsPublisher.swift index e463fa0..58d4ac5 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/ObservableType+AsPublisher.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/ObservableType+AsPublisher.swift @@ -7,7 +7,6 @@ import Combine import RxSwift extension ObservableType { - /// A bridging function that transforms an RxSwift `ObservableType` into a Combine `Publisher`. /// /// There is a fundamental difference between Combine and RxSwift around the concept of back pressure and how it is handled. @@ -29,13 +28,12 @@ extension ObservableType { withBufferSize size: Int, andBridgeBufferingStrategy whenFull: BridgeBufferingStrategy ) -> Publishers.MapError>, Error> { - return ObservableTypeBridgePublisher(upstream: self) .buffer(size: size, prefetch: .byRequest, whenFull: whenFull.strategy) .mapError { error -> Error in switch error { - case BridgeFailure.upstreamError(let upstreamError): return upstreamError - default: return error + case let BridgeFailure.upstreamError(upstreamError): return upstreamError + default: return error } } } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publisher+AssertBridgeBufferDoesNotOverflowIfPossible.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publisher+AssertBridgeBufferDoesNotOverflowIfPossible.swift index 6cc53b3..5ac4de2 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publisher+AssertBridgeBufferDoesNotOverflowIfPossible.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publisher+AssertBridgeBufferDoesNotOverflowIfPossible.swift @@ -7,7 +7,6 @@ import Foundation import Combine extension Publisher { - /// Convenience method whose default implementation causes a `preconditionFailure` when an upstream `BridgePublisher`'s buffer overflows. /// In the event this does not occur, the failure type is mapped to the `Error` type of the upstream `Observable`. /// @@ -18,13 +17,12 @@ extension Publisher { public func assertBridgeBufferDoesNotOverflowIfPossible( onBufferOverflow: @escaping () -> Error = { preconditionFailure("Bridge buffer overflowed.") } ) -> Publishers.MapError { - return mapError { error -> Error in guard let bridgeFailure = error as? BridgeFailure else { return error } switch bridgeFailure { - case .bufferOverflow: return onBufferOverflow() - case .upstreamError(let upstreamError): return upstreamError + case .bufferOverflow: return onBufferOverflow() + case let .upstreamError(upstreamError): return upstreamError } } } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/InfallibleTypeBridgePublisher.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/InfallibleTypeBridgePublisher.swift index a6405a7..d6ba2d3 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/InfallibleTypeBridgePublisher.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/InfallibleTypeBridgePublisher.swift @@ -8,7 +8,6 @@ import RxSwift /// A `Publisher` that handles subscriptions from an upstream `InfallibleType`. public struct InfallibleTypeBridgePublisher: Publisher { - public typealias Output = U.Element public typealias Failure = Never diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/ObservableTypeBridgePublisher.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/ObservableTypeBridgePublisher.swift index 9a80399..8f314c5 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/ObservableTypeBridgePublisher.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/Publishers/ObservableTypeBridgePublisher.swift @@ -8,7 +8,6 @@ import RxSwift /// A `Publisher` that handles subscriptions from an upstream `ObservableType`. public struct ObservableTypeBridgePublisher: Publisher { - public typealias Output = U.Element public typealias Failure = BridgeFailure diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription+Witness.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription+Witness.swift index aef6096..95613a6 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription+Witness.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription+Witness.swift @@ -7,33 +7,31 @@ import Foundation import RxSwift // MARK: - ObservableType -extension BridgeSubscription.Witness where U: ObservableType, U.Element == D.Input, D.Failure == BridgeFailure { +extension BridgeSubscription.Witness where U: ObservableType, U.Element == D.Input, D.Failure == BridgeFailure { static var observableType: Self { Self( subscribe: { upstream, downstream in - upstream - .subscribe( - onNext: { value in _ = downstream.receive(value) }, - onError: { error in downstream.receive(completion: .failure(.upstreamError(error))) }, - onCompleted: { downstream.receive(completion: .finished) } - ) + upstream.subscribe( + onNext: { value in _ = downstream.receive(value) }, + onError: { error in downstream.receive(completion: .failure(.upstreamError(error))) }, + onCompleted: { downstream.receive(completion: .finished) } + ) } ) } } // MARK: - InfallibleType -extension BridgeSubscription.Witness where U: InfallibleType, U.Element == D.Input, D.Failure == Never { +extension BridgeSubscription.Witness where U: InfallibleType, U.Element == D.Input, D.Failure == Never { static var infallibleType: Self { Self( subscribe: { upstream, downstream in - upstream - .subscribe( - onNext: { value in _ = downstream.receive(value) }, - onCompleted: { downstream.receive(completion: .finished) } - ) + upstream.subscribe( + onNext: { value in _ = downstream.receive(value) }, + onCompleted: { downstream.receive(completion: .finished) } + ) } ) } diff --git a/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription.swift b/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription.swift index dbfff55..fed0531 100644 --- a/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription.swift +++ b/Sources/CombineRx/Interoperability/RxSwift to Combine/Subscriptions/BridgeSubscription.swift @@ -7,7 +7,6 @@ import Combine import RxSwift final class BridgeSubscription: Subscription { - enum Status { case active(disposeBag: DisposeBag) case pending