File tree Expand file tree Collapse file tree 4 files changed +24
-6
lines changed
Sources/ComposableArchitecture
Tests/ComposableArchitectureTests Expand file tree Collapse file tree 4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ final class RootCore<Root: Reducer>: Core {
128
128
}
129
129
boxedTask. wrappedValue = task
130
130
tasks. withValue { $0. append ( task) }
131
- self . effectCancellables [ uuid] = AnyCancellable {
131
+ self . effectCancellables [ uuid] = AnyCancellable { @ Sendable in
132
132
task. cancel ( )
133
133
}
134
134
}
@@ -169,7 +169,7 @@ final class RootCore<Root: Reducer>: Core {
169
169
self ? . effectCancellables [ uuid] = nil
170
170
}
171
171
tasks. withValue { $0. append ( task) }
172
- self . effectCancellables [ uuid] = AnyCancellable {
172
+ self . effectCancellables [ uuid] = AnyCancellable { @ Sendable in
173
173
task. cancel ( )
174
174
}
175
175
}
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ extension Effect {
58
58
59
59
let cancellable = LockIsolated < AnyCancellable ? > ( nil )
60
60
cancellable. setValue (
61
- AnyCancellable {
61
+ AnyCancellable { @ Sendable in
62
62
_cancellationCancellables. withValue {
63
63
cancellationSubject. send ( ( ) )
64
64
cancellationSubject. send ( completion: . finished)
@@ -179,7 +179,7 @@ extension Effect {
179
179
$0. cancel ( id: id, path: navigationIDPath)
180
180
}
181
181
let task = Task { try await operation ( ) }
182
- let cancellable = AnyCancellable { task. cancel ( ) }
182
+ let cancellable = AnyCancellable { @ Sendable in task. cancel ( ) }
183
183
$0. insert ( cancellable, at: id, path: navigationIDPath)
184
184
return ( cancellable, task)
185
185
}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public struct _EffectPublisher<Action>: Publisher {
36
36
defer { subscriber. send ( completion: . finished) }
37
37
await operation ( Send { subscriber. send ( $0) } )
38
38
}
39
- return AnyCancellable {
39
+ return AnyCancellable { @ Sendable in
40
40
task. cancel ( )
41
41
}
42
42
}
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ final class StoreLifetimeTests: BaseTCATestCase {
69
69
}
70
70
71
71
@MainActor
72
- func testStoreDeinit_RunningEffect ( ) async {
72
+ func testStoreDeinit_RunningEffect_MainActor ( ) async {
73
73
Logger . shared. isEnabled = true
74
74
let effectFinished = self . expectation ( description: " Effect finished " )
75
75
do {
@@ -95,6 +95,24 @@ final class StoreLifetimeTests: BaseTCATestCase {
95
95
await self . fulfillment ( of: [ effectFinished] , timeout: 0.5 )
96
96
}
97
97
98
+ func testStoreDeinit_RunningEffect( ) async {
99
+ let effectFinished = self . expectation ( description: " Effect finished " )
100
+ do {
101
+ let store = await Store < Void , Void > ( initialState: ( ) ) {
102
+ Reduce { state, _ in
103
+ . run { _ in
104
+ try ? await Task . never ( )
105
+ effectFinished. fulfill ( )
106
+ }
107
+ }
108
+ }
109
+ await store. send ( ( ) )
110
+ _ = store
111
+ }
112
+
113
+ await self . fulfillment ( of: [ effectFinished] , timeout: 0.5 )
114
+ }
115
+
98
116
@MainActor
99
117
func testStoreDeinit_RunningCombineEffect( ) async {
100
118
Logger . shared. isEnabled = true
You can’t perform that action at this time.
0 commit comments