2 Commits

Author SHA1 Message Date
Sergej Jaskiewicz c805f0f5aa Bump the version to 0.10.2 (#188) 2020-10-23 15:29:02 +03:00
Sergej Jaskiewicz cb99f8b298 Make downstreamSubject a weak property in SubjectSubscriber (#187)
This is how it is in Combine.

Fixes #186.
2020-10-23 13:48:43 +03:00
6 changed files with 31 additions and 15 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "OpenCombine"
spec.version = "0.10.1"
spec.version = "0.10.2"
spec.summary = "Open source implementation of Apple's Combine framework for processing values over time."
spec.description = <<-DESC
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "OpenCombineDispatch"
spec.version = "0.10.1"
spec.version = "0.10.2"
spec.summary = "OpenCombine + Dispatch interoperability"
spec.description = <<-DESC
@@ -21,5 +21,5 @@ Pod::Spec.new do |spec|
spec.tvos.deployment_target = "9.0"
spec.source_files = "Sources/OpenCombineDispatch/**/*.swift"
spec.dependency "OpenCombine", '>= 0.9'
spec.dependency "OpenCombine", '>= 0.10.1'
end
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "OpenCombineFoundation"
spec.version = "0.10.1"
spec.version = "0.10.2"
spec.summary = "OpenCombine + OpenCombineFoundation interoperability"
spec.description = <<-DESC
@@ -21,5 +21,5 @@ Pod::Spec.new do |spec|
spec.tvos.deployment_target = "9.0"
spec.source_files = "Sources/OpenCombineFoundation/**/*.swift"
spec.dependency "OpenCombine", '>= 0.9'
spec.dependency "OpenCombine", '>= 0.10.1'
end
+4 -4
View File
@@ -23,7 +23,7 @@ To add `OpenCombine` to your [SPM](https://swift.org/package-manager/) package,
```swift
dependencies: [
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.10.1")
.package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.10.2")
],
targets: [
.target(name: "MyAwesomePackage", dependencies: ["OpenCombine",
@@ -46,9 +46,9 @@ To do so, open Xcode, use **File** → **Swift Packages** → **Add Package Depe
To add `OpenCombine` to a project using [CocoaPods](https://cocoapods.org/), add `OpenCombine` and `OpenCombineDispatch` to the list of target dependencies in your `Podfile`.
```ruby
pod 'OpenCombine', '~> 0.10.1'
pod 'OpenCombineDispatch', '~> 0.10.1'
pod 'OpenCombineFoundation', '~> 0.10.1'
pod 'OpenCombine', '~> 0.10.2'
pod 'OpenCombineDispatch', '~> 0.10.2'
pod 'OpenCombineFoundation', '~> 0.10.2'
```
### Contributing
@@ -5,7 +5,6 @@
// Created by Sergej Jaskiewicz on 16/09/2019.
//
// NOTE: This class has been audited for thread safety.
internal final class SubjectSubscriber<Downstream: Subject>
: Subscriber,
CustomStringConvertible,
@@ -14,7 +13,7 @@ internal final class SubjectSubscriber<Downstream: Subject>
Subscription
{
private let lock = UnfairLock.allocate()
private var downstreamSubject: Downstream?
private weak var downstreamSubject: Downstream?
private var upstreamSubscription: Subscription?
private var isCancelled: Bool { return downstreamSubject == nil }
@@ -146,6 +146,8 @@ final class MulticastTests: XCTestCase {
.value(7),
.completion(.finished),
.subscriber])
connection.cancel()
}
func testSubscribeAfterCompletion() {
@@ -288,6 +290,19 @@ final class MulticastTests: XCTestCase {
}
}
func testDeallocateConnectedMulticastBeforeCancelling() {
// https://github.com/OpenCombine/OpenCombine/issues/186
let publisher = CustomPublisher(subscription: CustomSubscription())
var subjectDestroyed = false
var subject: TrackingSubject<Int>? = .init(onDeinit: { subjectDestroyed = true })
let connection = publisher.multicast(subject: subject!).connect()
subject = nil
XCTAssertTrue(subjectDestroyed)
connection.cancel() // Shouldn't recursively aquire a non-recursive lock here.
}
func testLazySubjectCreation() {
let publisher = PassthroughSubject<Int, TestingError>()
var counter = 0
@@ -406,10 +421,12 @@ final class MulticastTests: XCTestCase {
publisher.send(42)
publisher.send(completion: .finished)
XCTAssertEqual(tracking.history, [.subscription("Multicast"),
.value(42),
.value(42),
.completion(.finished)])
withExtendedLifetime(multicast) {
XCTAssertEqual(tracking.history, [.subscription("Multicast"),
.value(42),
.value(42),
.completion(.finished)])
}
connection1.cancel()
connection2.cancel()