mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* `@preconcurrency @MainActor` isolation of `Store` * Remove unneeded `@MainActor`s * Remove thread checking code * Remove unneeded `@MainActor`s * Swift 5.10 compatibility fixes * wip * More 5.10 fixes * wip * fixes * wip * wip * up the timeout * wip * Fixes * wip * wip * wip * wip * wip * Fix binding action sendability * Address more binding action sendability * more bindable action sendability * more bindable action warnings * fix * Make `Effect.map` sendable * Make `Effect.actions` sendable Also moves it to the test target, since it's only really used there. * Make `AnyPublisher.create` sendable * Make `_SynthesizedConformance` sendable * Avoid non-sendable captures of `self` in reducers We can capture the sendable case path instead. * Make `ViewStore.yield` sendable * Address internal sendability warning * fix * Another small warning --------- Co-authored-by: Brandon Williams <mbrandonw@hey.com>
29 lines
862 B
Swift
29 lines
862 B
Swift
@preconcurrency import Combine
|
|
|
|
extension Effect where Action: Sendable {
|
|
@_spi(Internals) public var actions: AsyncStream<Action> {
|
|
switch self.operation {
|
|
case .none:
|
|
return .finished
|
|
case let .publisher(publisher):
|
|
return AsyncStream { continuation in
|
|
let cancellable = publisher.sink(
|
|
receiveCompletion: { _ in continuation.finish() },
|
|
receiveValue: { continuation.yield($0) }
|
|
)
|
|
continuation.onTermination = { _ in
|
|
cancellable.cancel()
|
|
}
|
|
}
|
|
case let .run(priority, operation):
|
|
return AsyncStream { continuation in
|
|
let task = Task(priority: priority) {
|
|
await operation(Send { action in continuation.yield(action) })
|
|
continuation.finish()
|
|
}
|
|
continuation.onTermination = { _ in task.cancel() }
|
|
}
|
|
}
|
|
}
|
|
}
|