diff --git a/Package.swift b/Package.swift index 2cfea541..0a4d2efb 100644 --- a/Package.swift +++ b/Package.swift @@ -185,7 +185,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { .library(name: "BottomMenu", targets: ["BottomMenu"]), .library(name: "ChangelogFeature", targets: ["ChangelogFeature"]), .library(name: "ClientModels", targets: ["ClientModels"]), - .library(name: "CombineHelpers", targets: ["CombineHelpers"]), .library(name: "ComposableGameCenter", targets: ["ComposableGameCenter"]), .library(name: "ComposableStoreKit", targets: ["ComposableStoreKit"]), .library(name: "ComposableUserNotifications", targets: ["ComposableUserNotifications"]), @@ -399,13 +398,9 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { "__Snapshots__" ] ), - .target( - name: "CombineHelpers" - ), .target( name: "ComposableGameCenter", dependencies: [ - "CombineHelpers", "FirstPartyMocks", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "Overture", package: "swift-overture"), @@ -557,7 +552,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { name: "FileClient", dependencies: [ "ClientModels", - "CombineHelpers", "XCTestDebugSupport", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"), @@ -611,7 +605,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { "ApiClient", "AudioPlayerClient", "ClientModels", - "CombineHelpers", "ComposableStoreKit", "DailyChallengeHelpers", "FileClient", @@ -671,7 +664,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { "Build", "ChangelogFeature", "ClientModels", - "CombineHelpers", "ComposableStoreKit", "ComposableUserNotifications", "DailyChallengeFeature", @@ -779,7 +771,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { .target( name: "NotificationsAuthAlert", dependencies: [ - "CombineHelpers", "ComposableUserNotifications", "NotificationHelpers", "RemoteNotificationsClient", @@ -946,7 +937,6 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil { .target( name: "UpgradeInterstitialFeature", dependencies: [ - "CombineHelpers", "ComposableStoreKit", "ServerConfigClient", "Styleguide", diff --git a/Sources/CombineHelpers/Combine.swift b/Sources/CombineHelpers/Combine.swift deleted file mode 100644 index d45b2189..00000000 --- a/Sources/CombineHelpers/Combine.swift +++ /dev/null @@ -1,35 +0,0 @@ -import Combine - -extension Publisher where Output == Never { - public func setOutputType(to _: NewOutput.Type) -> AnyPublisher { - func absurd(_ never: Never) -> A {} - return self.map(absurd).eraseToAnyPublisher() - } -} - -extension Publisher { - public func ignoreOutput( - setOutputType: NewOutput.Type - ) -> AnyPublisher { - return - self - .ignoreOutput() - .setOutputType(to: NewOutput.self) - } - - public func ignoreFailure( - setFailureType: NewFailure.Type - ) -> AnyPublisher { - self - .catch { _ in Empty() } - .setFailureType(to: NewFailure.self) - .eraseToAnyPublisher() - } - - public func ignoreFailure() -> AnyPublisher { - self - .catch { _ in Empty() } - .setFailureType(to: Never.self) - .eraseToAnyPublisher() - } -} diff --git a/Sources/CombineHelpers/ReplaySubject.swift b/Sources/CombineHelpers/ReplaySubject.swift deleted file mode 100644 index 1eafd0e3..00000000 --- a/Sources/CombineHelpers/ReplaySubject.swift +++ /dev/null @@ -1,94 +0,0 @@ -import Combine -import Foundation - -// Adapted from https://www.onswiftwings.com/posts/share-replay-operator/ -public final class ReplaySubject: Subject { - private var buffer = [Output]() - private let bufferSize: Int - private var subscriptions = [Subscription]() - private var completion: Subscribers.Completion? - private let lock = NSRecursiveLock() - - public init(_ bufferSize: Int = 0) { - self.bufferSize = bufferSize - } - - public func send(subscription: Combine.Subscription) { - self.lock.self.lock() - defer { self.lock.unlock() } - subscription.request(.unlimited) - } - - public func send(_ value: Output) { - self.lock.lock() - defer { self.lock.unlock() } - self.buffer.append(value) - self.buffer = self.buffer.suffix(bufferSize) - self.subscriptions.forEach { $0.receive(value) } - } - - public func send(completion: Subscribers.Completion) { - self.lock.lock() - defer { self.lock.unlock() } - self.completion = completion - self.subscriptions.forEach { $0.receive(completion: completion) } - } - - public func receive(subscriber: Downstream) - where Downstream.Failure == Failure, Downstream.Input == Output { - self.lock.lock() - defer { self.lock.unlock() } - let subscription = Subscription(downstream: AnySubscriber(subscriber)) - subscriber.receive(subscription: subscription) - self.subscriptions.append(subscription) - subscription.replay(self.buffer, completion: self.completion) - } - - private final class Subscription: Combine.Subscription { - private let downstream: AnySubscriber - private var isCompleted = false - private var demand: Subscribers.Demand = .none - - init(downstream: AnySubscriber) { - self.downstream = downstream - } - - func request(_ newDemand: Subscribers.Demand) { - self.demand += newDemand - } - - func cancel() { - self.isCompleted = true - } - - public func receive(_ value: Output) { - guard !self.isCompleted, self.demand > 0 else { return } - self.demand += self.downstream.receive(value) - self.demand -= 1 - } - - public func receive(completion: Subscribers.Completion) { - guard !self.isCompleted else { return } - self.isCompleted = true - self.downstream.receive(completion: completion) - } - - public func replay(_ values: [Output], completion: Subscribers.Completion?) { - guard !isCompleted else { return } - values.forEach { value in self.receive(value) } - if let completion = completion { self.receive(completion: completion) } - } - } -} - -extension Publisher { - public func shareReplay( - _ bufferSize: Int - ) - -> Publishers.Autoconnect>> - { - self - .multicast(subject: ReplaySubject(bufferSize)) - .autoconnect() - } -} diff --git a/Sources/NotificationsAuthAlert/NotificationsAuthAlert.swift b/Sources/NotificationsAuthAlert/NotificationsAuthAlert.swift index 5c4c09ac..ca4ce5fc 100644 --- a/Sources/NotificationsAuthAlert/NotificationsAuthAlert.swift +++ b/Sources/NotificationsAuthAlert/NotificationsAuthAlert.swift @@ -1,5 +1,4 @@ import Combine -import CombineHelpers import ComposableArchitecture import ComposableUserNotifications import NotificationHelpers