Skip to content
This repository has been archived by the owner on Feb 2, 2025. It is now read-only.

Only add Combine Support if Module can be Imported #2

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/SwiftCoroutine/Combine/CoFuture+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import Combine

@available(OSX 10.15, iOS 13.0, *)
Expand Down Expand Up @@ -35,3 +36,4 @@ extension Subscriber {
}

}
#endif
2 changes: 2 additions & 0 deletions Sources/SwiftCoroutine/Combine/CoPromise+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import Combine

@available(OSX 10.15, iOS 13.0, *)
Expand All @@ -23,3 +24,4 @@ extension CoPromise: Subject {
}

}
#endif
2 changes: 2 additions & 0 deletions Sources/SwiftCoroutine/Combine/CoSubscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import Combine

@available(OSX 10.15, iOS 13.0, *)
Expand Down Expand Up @@ -38,3 +39,4 @@ extension CoSubscription: Hashable {
}

}
#endif
2 changes: 2 additions & 0 deletions Sources/SwiftCoroutine/Combine/Dispatcher+Scheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import Combine

@available(OSX 10.15, iOS 13.0, *)
Expand All @@ -20,3 +21,4 @@ extension Coroutine.Dispatcher {
}

}
#endif
2 changes: 2 additions & 0 deletions Sources/SwiftCoroutine/Combine/Publisher+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import Combine
import Dispatch

Expand All @@ -26,3 +27,4 @@ extension Publisher {
}

}
#endif
15 changes: 14 additions & 1 deletion Sources/SwiftCoroutine/Protocols/CoCancellable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2020 Alex Belozierov. All rights reserved.
//

#if !canImport(Combine)

import Combine

public protocol CoCancellable: Cancellable, Hashable {
Expand All @@ -15,6 +17,17 @@ public protocol CoCancellable: Cancellable, Hashable {

}

#else

public protocol CoCancellable: Hashable {

func cancel()
func cancelUpstream()

}

#endif

extension CoCancellable where Self: AnyObject {

@inlinable public var anyCoCancellable: AnyCoCancellable {
Expand Down Expand Up @@ -47,5 +60,5 @@ final public class AnyCoCancellable: CoCancellable {
@inlinable public func hash(into hasher: inout Hasher) {
ObjectIdentifier(self).hash(into: &hasher)
}

}
2 changes: 2 additions & 0 deletions Tests/SwiftCoroutineTests/CombineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Alex Belozierov. All rights reserved.
//

#if canImport(Combine)
import XCTest
import Combine
import SwiftCoroutine
Expand Down Expand Up @@ -35,3 +36,4 @@ class CombineTests: XCTestCase {
}

}
#endif