Skip to content

Commit b9b7ea7

Browse files
authored
Merge branch 'hotfix-1.0.1' into signal-deadlock-fix
2 parents 403e4c7 + ef9718e commit b9b7ea7

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Sources/Action.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public final class Action<Input, Output, Error: Swift.Error> {
102102
}
103103
}
104104

105-
self.isEnabled = state.map { $0.isEnabled }
106-
self.isExecuting = state.map { $0.isExecuting }
105+
self.isEnabled = state.map { $0.isEnabled }.skipRepeats()
106+
self.isExecuting = state.map { $0.isExecuting }.skipRepeats()
107107
}
108108

109109
/// Initializes an action that will be conditionally enabled, and creates a

Tests/ReactiveSwiftTests/ActionSpec.swift

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import Foundation
10-
10+
import Dispatch
1111
import Result
1212
import Nimble
1313
import Quick
@@ -137,6 +137,36 @@ class ActionSpec: QuickSpec {
137137
action1.apply().start()
138138
}
139139

140+
if #available(macOS 10.10, *) {
141+
it("should not loop indefinitely") {
142+
let condition = MutableProperty(1)
143+
144+
let action = Action<Void, Void, NoError>(state: condition, enabledIf: { $0 == 0 }) { _ in
145+
return .empty
146+
}
147+
148+
let disposable = CompositeDisposable()
149+
150+
waitUntil(timeout: 0.01) { done in
151+
let target = DispatchQueue(label: "test target queue")
152+
let highPriority = QueueScheduler(qos: .userInitiated, targeting: target)
153+
let lowPriority = QueueScheduler(qos: .default, targeting: target)
154+
155+
disposable += action.isExecuting.producer
156+
.observe(on: highPriority)
157+
.startWithValues { _ in
158+
condition.value = 10
159+
}
160+
161+
disposable += lowPriority.schedule {
162+
done()
163+
}
164+
}
165+
166+
disposable.dispose()
167+
}
168+
}
169+
140170
describe("completed") {
141171
beforeEach {
142172
enabled.value = true

0 commit comments

Comments
 (0)