Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 5.9+ #7

Merged
merged 4 commits into from
Sep 4, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Release Notes

All notable changes to this project will be documented in this file.

**2023-09-04**

- Swift 5.9+

**2021-06-02**

- Expose the `AsynchronousOperation` target.
Expand Down
24 changes: 11 additions & 13 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"object": {
"pins": [
{
"package": "CombineExpectations",
"repositoryURL": "https://github.com/groue/CombineExpectations.git",
"state": {
"branch": null,
"revision": "5c36f3199960776fc055196a93ca04bfc00e1857",
"version": "0.7.0"
}
"pins" : [
{
"identity" : "combineexpectations",
"kind" : "remoteSourceControl",
"location" : "https://github.com/groue/CombineExpectations.git",
"state" : {
"revision" : "04d4e4b21c9e8361925f03f64a7ecda89ef9974f",
"version" : "0.10.0"
}
]
},
"version": 1
}
],
"version" : 2
}
44 changes: 31 additions & 13 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let swiftSettings: [SwiftSetting] = [
// Uncomment in order to perform complete concurrency checking
// .enableExperimentalFeature("StrictConcurrency"),
.enableExperimentalFeature("ExistentialAny"),
]

let package = Package(
name: "CombineTraits",
platforms: [
.iOS("13.0"),
.macOS("10.15"),
.tvOS("13.0"),
.watchOS("6.0"),
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -18,7 +24,7 @@ let package = Package(
targets: ["AsynchronousOperation"]),
.library(
name: "CombineTraits",
targets: ["CombineTraits"]),
targets: ["CombineTraits", "AsynchronousOperation", "CancelBag"]),
.library(
name: "CancelBag",
targets: ["CancelBag"]),
Expand All @@ -33,24 +39,36 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "CombineTraits",
dependencies: ["AsynchronousOperation", "CancelBag"]),
dependencies: ["AsynchronousOperation", "CancelBag"],
swiftSettings: swiftSettings
),
.testTarget(
name: "CombineTraitsTests",
dependencies: ["CombineTraits", "CombineExpectations"]),
dependencies: ["CombineTraits", "AsynchronousOperation", "CancelBag", "CombineExpectations"],
swiftSettings: swiftSettings
),
.testTarget(
name: "CombineTraitsAsynchronousOperationTests",
dependencies: ["CombineTraits", "CombineExpectations"]),
dependencies: ["CombineTraits", "AsynchronousOperation", "CancelBag", "CombineExpectations"],
swiftSettings: swiftSettings
),
.testTarget(
name: "CombineTraitsCancelBagTests",
dependencies: ["CombineTraits"]),
dependencies: ["CombineTraits", "AsynchronousOperation", "CancelBag"],
swiftSettings: swiftSettings
),
.target(
name: "CancelBag",
dependencies: []),
swiftSettings: swiftSettings
),
.testTarget(
name: "CancelBagTests",
dependencies: ["CancelBag"]),
dependencies: ["CancelBag"],
swiftSettings: swiftSettings
),
.target(
name: "AsynchronousOperation",
dependencies: []),
swiftSettings: swiftSettings
),
]
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CombineTraits [![Swift 5.3](https://img.shields.io/badge/swift-5.3-orange.svg?style=flat)](https://developer.apple.com/swift/)
CombineTraits [![Swift 5.9](https://img.shields.io/badge/swift-5.9-orange.svg?style=flat)](https://developer.apple.com/swift/)
=============

### Combine Publishers with Guarantees

**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ • Swift 5.3+ / Xcode 12.0+
**Requirements**: iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+ • Swift 5.9+ / Xcode 15.0+

---

Expand Down
2 changes: 1 addition & 1 deletion Sources/AsynchronousOperation/AsynchronousOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ open class AsynchronousOperation<Output, Failure: Error>: Operation {
completionBlock = { [unowned self] in
let result = self.result
assert(result != nil || self.isCancelled)
if let queue = queue {
if let queue {
queue.async {
resultHandler(result)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/CancelBag/CancelBag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ extension Publisher {
receiveCancel: { [weak cancellables] in
// Postpone cleanup in case subscription finishes
// before cancellable is set.
if let unmanagedCancellable = unmanagedCancellable {
if let unmanagedCancellable {
cancellables?.remove(unmanagedCancellable.takeUnretainedValue())
unmanagedCancellable.release()
} else {
DispatchQueue.main.async {
if let unmanagedCancellable = unmanagedCancellable {
if let unmanagedCancellable {
cancellables?.remove(unmanagedCancellable.takeUnretainedValue())
unmanagedCancellable.release()
}
Expand All @@ -134,12 +134,12 @@ extension Publisher {
receiveCompletion(completion)
// Postpone cleanup in case subscription finishes
// before cancellable is set.
if let unmanagedCancellable = unmanagedCancellable {
if let unmanagedCancellable {
cancellables?.remove(unmanagedCancellable.takeUnretainedValue())
unmanagedCancellable.release()
} else {
DispatchQueue.main.async {
if let unmanagedCancellable = unmanagedCancellable {
if let unmanagedCancellable {
cancellables?.remove(unmanagedCancellable.takeUnretainedValue())
unmanagedCancellable.release()
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/CombineTraits/Exported.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/CombineTraits/ImmediatePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ extension AnyImmediatePublisher where Failure == Never {
extension AnyImmediatePublisher {
/// Creates an `AnyImmediatePublisher` which emits one value, and
/// then finishes.
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure) -> Self {
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure.self) -> Self {
Just(value)
.setFailureType(to: failureType)
.eraseToAnyImmediatePublisher()
Expand Down
4 changes: 2 additions & 2 deletions Sources/CombineTraits/MaybePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ extension MaybePublisher {
map { Optional.some($0) }
.replaceEmpty(with: nil)
.flatMap { output -> AnySinglePublisher<Output, Failure> in
if let output = output {
if let output {
return .just(output)
} else {
return .fail(error)
Expand Down Expand Up @@ -374,7 +374,7 @@ extension AnyMaybePublisher {

/// Creates an `AnyMaybePublisher` which emits one value, and
/// then finishes.
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure) -> Self {
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure.self) -> Self {
Just(value)
.setFailureType(to: failureType)
.eraseToAnyMaybePublisher()
Expand Down
2 changes: 1 addition & 1 deletion Sources/CombineTraits/SinglePublisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ extension AnySinglePublisher where Failure == Never {
extension AnySinglePublisher {
/// Creates an `AnySinglePublisher` which emits one value, and
/// then finishes.
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure) -> Self {
public static func just(_ value: Output, failureType: Failure.Type = Self.Failure.self) -> Self {
Just(value)
.setFailureType(to: failureType)
.eraseToAnySinglePublisher()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CancelBag
import Combine
import CombineTraits
import XCTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CancelBag
import Combine
import CombineTraits
import XCTest
Expand Down
Loading