Skip to content

Commit 5eedf98

Browse files
authored
Deprecate async version of withValue and introduce sync version. (#1792)
1 parent ce196d7 commit 5eedf98

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Sources/ComposableArchitecture/Effects/ConcurrencySupport.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ public final actor ActorIsolated<Value: Sendable> {
325325
/// - Parameters: operation: An operation to be performed on the actor with the underlying value.
326326
/// - Returns: The result of the operation.
327327
public func withValue<T: Sendable>(
328-
_ operation: @Sendable (inout Value) async throws -> T
329-
) async rethrows -> T {
328+
_ operation: @Sendable (inout Value) throws -> T
329+
) rethrows -> T {
330330
var value = self.value
331331
defer { self.value = value }
332-
return try await operation(&value)
332+
return try operation(&value)
333333
}
334334

335335
/// Overwrite the isolated value with a new value.

Sources/ComposableArchitecture/Internal/Deprecations.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ import Combine
33
import SwiftUI
44
import XCTestDynamicOverlay
55

6+
// MARK: - Deprecated after 0.47.2
7+
8+
extension ActorIsolated {
9+
@available(
10+
*,
11+
deprecated,
12+
message: "Use the non-async version of 'withValue'."
13+
)
14+
public func withValue<T: Sendable>(
15+
_ operation: @Sendable (inout Value) async throws -> T
16+
) async rethrows -> T {
17+
var value = self.value
18+
defer { self.value = value }
19+
return try await operation(&value)
20+
}
21+
}
22+
623
// MARK: - Deprecated after 0.45.0:
724

825
@available(

0 commit comments

Comments
 (0)