Skip to content

Commit bd14b2e

Browse files
committed
Force effect tasks to be on @mainactor. (#1131)
1 parent 1abeaaf commit bd14b2e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Sources/ComposableArchitecture/Effects/Concurrency.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import ReactiveSwift
3939
) -> Self where Error == Never {
4040
var task: Task<Void, Never>?
4141
return .future { callback in
42-
task = Task(priority: priority) {
42+
task = Task(priority: priority) { @MainActor in
4343
guard !Task.isCancelled else { return }
4444
let output = await operation()
4545
guard !Task.isCancelled else { return }
@@ -84,20 +84,20 @@ import ReactiveSwift
8484
deferred {
8585
var task: Task<(), Never>?
8686
let producer = SignalProducer { observer, lifetime in
87-
task = Task(priority: priority) {
88-
do {
89-
try Task.checkCancellation()
90-
let output = try await operation()
91-
try Task.checkCancellation()
87+
task = Task(priority: priority) { @MainActor in
88+
do {
89+
try Task.checkCancellation()
90+
let output = try await operation()
91+
try Task.checkCancellation()
9292
observer.send(value: output)
9393
observer.sendCompleted()
94-
} catch is CancellationError {
94+
} catch is CancellationError {
9595
observer.sendCompleted()
96-
} catch {
96+
} catch {
9797
observer.send(error: error)
98-
}
9998
}
10099
}
100+
}
101101

102102
return producer.on(disposed: task?.cancel)
103103
}

0 commit comments

Comments
 (0)