Skip to content

Commit

Permalink
Merge pull request #87 from Fueled/refactor/remove-can-import-checks
Browse files Browse the repository at this point in the history
Remove non-needed canImport checks
  • Loading branch information
hadiidbouk authored Jan 8, 2024
2 parents 580e55d + fa45d6f commit 0311b12
Show file tree
Hide file tree
Showing 19 changed files with 4 additions and 65 deletions.
4 changes: 0 additions & 4 deletions Sources/FueledUtils/Combine/ActionError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(FueledUtilsReactiveCommon)
import FueledUtilsReactiveCommon
#endif

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public enum ActionError<Error: Swift.Error>: Swift.Error {
case disabled
Expand Down
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/ActionProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -105,5 +104,3 @@ extension ActionProtocol where Input == Void {
return self.apply(())
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/AnyAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

///
Expand Down Expand Up @@ -64,5 +63,3 @@ public final class AnyAction: ActionProtocol {
self.applyClosure(input)
}
}

#endif
14 changes: 4 additions & 10 deletions Sources/FueledUtils/Combine/AnyCurrentValuePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine
#if canImport(FueledUtilsReactiveCommon)
import FueledUtilsReactiveCommon
#endif

///
/// A type-erasing current value publisher.
Expand All @@ -27,24 +23,24 @@ import FueledUtilsReactiveCommon
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public struct AnyCurrentValuePublisher<Output, Failure: Swift.Error>: CurrentValuePublisher {
private let valueGetter: () -> Output
private let receiveSubcriberClosure: (AnySubscriber<Output, Failure>) -> Void
private let receiveSubscriberClosure: (AnySubscriber<Output, Failure>) -> Void

public var value: Output {
self.valueGetter()
}

public init(_ value: Output) {
self.valueGetter = { value }
self.receiveSubcriberClosure = { _ = $0.receive(value) }
self.receiveSubscriberClosure = { _ = $0.receive(value) }
}

public init<Publisher: CurrentValuePublisher>(_ publisher: Publisher) where Publisher.Output == Output, Publisher.Failure == Failure {
self.valueGetter = { publisher.value }
self.receiveSubcriberClosure = { publisher.receive(subscriber: $0) }
self.receiveSubscriberClosure = { publisher.receive(subscriber: $0) }
}

public func receive<Subscriber: Combine.Subscriber>(subscriber: Subscriber) where Subscriber.Input == Output, Subscriber.Failure == Failure {
self.receiveSubcriberClosure(subscriber.eraseToAnySubscriber())
self.receiveSubscriberClosure(subscriber.eraseToAnySubscriber())
}
}

Expand All @@ -66,5 +62,3 @@ public protocol CurrentValuePublisher: Publisher {
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
extension CurrentValueSubject: CurrentValuePublisher {
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -50,5 +49,3 @@ public func >>> (lhs: AnyCancellable?, rhs: inout Set<AnyCancellable>?) {
}
lhs >>> rhs
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/OverridingAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

///
Expand Down Expand Up @@ -101,5 +100,3 @@ public class OverridingAction<Input, Output, Failure: Swift.Error>: ActionProtoc
.eraseToAnyPublisher()
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/Published+PublisherInit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -47,5 +46,3 @@ extension Published {
return publisher
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Stéphane Copin on 10/14/20.
//

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -102,5 +101,3 @@ extension Publisher {
)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/Publisher+CombinePrevious.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -43,5 +42,3 @@ extension Publisher {
.eraseToAnyPublisher()
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/Publisher+IgnoreRepeats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -30,5 +29,3 @@ extension Publisher where Output: Equatable {
self.removeDuplicates(by: ==).eraseToAnyPublisher()
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/Combine/Subject+SendResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -27,5 +26,3 @@ extension Subject {
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(Combine)
import Combine

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -21,5 +20,3 @@ extension Subscriber {
AnySubscriber(self)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/BackgroundBlur.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -51,5 +50,3 @@ extension View {
}
#endif
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/Binding+KeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -28,5 +27,3 @@ extension Binding {
)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/BlurView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI
#if canImport(UIKit)
import UIKit
Expand Down Expand Up @@ -74,5 +73,3 @@ public struct BlurView: NSViewRepresentable {
}

#endif

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/EdgeInsets+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -34,5 +33,3 @@ extension EdgeInsets {
)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/ForEachWithIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand Down Expand Up @@ -72,5 +71,3 @@ private struct IndexInfo<Index, Element, ID: Hashable>: Hashable {
self.elementID.hash(into: &hasher)
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/FramePreferenceKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

///
Expand All @@ -29,5 +28,3 @@ public struct FramePreferenceKey<TagType>: PreferenceKey {
value = nextValue()
}
}

#endif
3 changes: 0 additions & 3 deletions Sources/FueledUtils/SwiftUI/View+AnyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if canImport(SwiftUI)
import SwiftUI

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
Expand All @@ -21,5 +20,3 @@ extension View {
AnyView(self)
}
}

#endif

0 comments on commit 0311b12

Please sign in to comment.