Skip to content

Commit

Permalink
Merge branch 'master' into swift-concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcocanc committed Nov 27, 2021
2 parents be62397 + efb2f0a commit d354eda
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,13 @@
# master
*Please add new entries at the top.*

# 7.0.0
1. The UnidirectionalBinding operator `<~` returns non optional values. (#834, kudos to @NicholasTD07)

1. Fixed issue where `SingalProducer.try(upTo:interval:count:)` shares state between invocation of `start` on the same producer. (#829, kudos to @sebastiangrail)

1. `Signal.Event` is now marked as frozen enum. (#841, kudos to @NachoSoto)

# 6.7.0
# 6.7.0-rc1
1. Add Swift Concurrency extensions `asyncStream` and `asyncThrowingStream` to `Signal` and `SignalProducer` (#847)
Expand Down Expand Up @@ -43,7 +50,6 @@
1. Bumped deployment target to iOS 9.0, per Xcode 12 warnings. (#818, kudos to @harleyjcooper)

1. Fixed a few deprecation warning when the project is being built. (#819, kudos to @apps4everyone)
>>>>>>> origin/master

# 6.5.0

Expand Down
2 changes: 1 addition & 1 deletion ReactiveSwift.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "ReactiveSwift"
# Version goes here and will be used to access the git tag later on, once we have a first release.
s.version = "6.7.0"
s.version = "7.0.0"
s.summary = "Streams of values over time"
s.description = <<-DESC
ReactiveSwift is a Swift framework inspired by Functional Reactive Programming. It provides APIs for composing and transforming streams of values over time.
Expand Down
7 changes: 5 additions & 2 deletions Sources/SignalProducer.swift
Expand Up @@ -2393,9 +2393,10 @@ extension SignalProducer {
return producer
}

var retries = count
return SignalProducer { observer, lifetime in
var retries = count

return flatMapError { error -> SignalProducer<Value, Error> in
lifetime += flatMapError { error -> SignalProducer<Value, Error> in
// The final attempt shouldn't defer the error if it fails
var producer = SignalProducer<Value, Error>(error: error)
if retries > 0 {
Expand All @@ -2408,6 +2409,8 @@ extension SignalProducer {
return producer
}
.retry(upTo: count)
.start(observer)
}
}

/// Wait for completion of `self`, *then* forward all events from
Expand Down
2 changes: 1 addition & 1 deletion Sources/UnidirectionalBinding.swift
Expand Up @@ -120,7 +120,7 @@ extension Signal.Observer {
@discardableResult
public static func <~
<Source: BindingSource>
(observer: Signal<Value, Error>.Observer, source: Source) -> Disposable?
(observer: Signal<Value, Error>.Observer, source: Source) -> Disposable
where Source.Value == Value
{
return source.producer.startWithValues { [weak observer] in
Expand Down
34 changes: 34 additions & 0 deletions Tests/ReactiveSwiftTests/SignalProducerSpec.swift
Expand Up @@ -2812,6 +2812,40 @@ class SignalProducerSpec: QuickSpec {
expect(errors) == [.default]
}

it("should not share retry counter across produced signals") {
let scheduler = TestScheduler()
var failuresReceived = 0

let original = SignalProducer<Int, TestError> { observer, _ in
scheduler.schedule { observer.send(error: .default) }
}
let retryDelay: DispatchTimeInterval = .seconds(1)
let retriable = original
.retry(upTo: 1, interval: retryDelay.timeInterval, on: scheduler)
.on(failed: { _ in failuresReceived += 1 })

// 1st produced signal
retriable.start()

scheduler.advance()
expect(failuresReceived) == 0

scheduler.advance(by: retryDelay)
expect(failuresReceived) == 1

// 2nd produced signal
retriable.start()

scheduler.advance()
// Shared retry counter had caused the second produced signal not to defer the failed event as expected.
// (https://github.com/ReactiveCocoa/ReactiveSwift/pull/829)
// Assert that we did not receive the 2th final failure at this point, which should always be delayed until
// at least `retryDelay` has elapsed.
expect(failuresReceived) == 1

scheduler.advance(by: retryDelay)
expect(failuresReceived) == 2
}
}

}
Expand Down

0 comments on commit d354eda

Please sign in to comment.