File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Sources/ComposableArchitecture/Effects Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,14 @@ extension Effect {
39
39
/// canceled before starting this new one.
40
40
/// - Returns: A new effect that is capable of being canceled by an identifier.
41
41
public func cancellable( id: AnyHashable , cancelInFlight: Bool = false ) -> Effect {
42
- let effect = Effect . deferred { ( ) -> SignalProducer < Value , Error > in
42
+ Effect . deferred { ( ) -> SignalProducer < Value , Error > in
43
43
cancellablesLock. lock ( )
44
44
defer { cancellablesLock. unlock ( ) }
45
45
46
+ if cancelInFlight {
47
+ cancellationCancellables [ id] ? . forEach { $0. dispose ( ) }
48
+ }
49
+
46
50
let subject = Signal < Value , Error > . pipe ( )
47
51
48
52
var values : [ Value ] = [ ]
@@ -82,8 +86,6 @@ extension Effect {
82
86
disposed: cancellationDisposable. dispose
83
87
)
84
88
}
85
-
86
- return cancelInFlight ? . concatenate( . cancel( id: id) , effect) : effect
87
89
}
88
90
89
91
/// An effect that will cancel any currently in-flight effect with the given identifier.
You can’t perform that action at this time.
0 commit comments