File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Sources/ComposableArchitecture/Effects Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ extension Effect {
43
43
cancellablesLock. lock ( )
44
44
defer { cancellablesLock. unlock ( ) }
45
45
46
+ let id = CancelToken ( id: id)
46
47
if cancelInFlight {
47
48
cancellationCancellables [ id] ? . forEach { $0. dispose ( ) }
48
49
}
@@ -96,7 +97,7 @@ extension Effect {
96
97
public static func cancel( id: AnyHashable ) -> Effect {
97
98
return . fireAndForget {
98
99
cancellablesLock. sync {
99
- cancellationCancellables [ id ] ? . forEach { $0. dispose ( ) }
100
+ cancellationCancellables [ . init ( id : id ) ] ? . forEach { $0. dispose ( ) }
100
101
}
101
102
}
102
103
}
@@ -111,5 +112,15 @@ extension Effect {
111
112
}
112
113
}
113
114
114
- var cancellationCancellables : [ AnyHashable : Set < AnyDisposable > ] = [ : ]
115
+ struct CancelToken : Hashable {
116
+ let id : AnyHashable
117
+ let discriminator : ObjectIdentifier
118
+
119
+ init ( id: AnyHashable ) {
120
+ self . id = id
121
+ self . discriminator = ObjectIdentifier ( type ( of: id. base) )
122
+ }
123
+ }
124
+
125
+ var cancellationCancellables : [ CancelToken : Set < AnyDisposable > ] = [ : ]
115
126
let cancellablesLock = NSRecursiveLock ( )
You can’t perform that action at this time.
0 commit comments