Skip to content

Deprecate async version of withValue and introduce sync version. #1792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ public final actor ActorIsolated<Value: Sendable> {
/// - Parameters: operation: An operation to be performed on the actor with the underlying value.
/// - Returns: The result of the operation.
public func withValue<T: Sendable>(
_ operation: @Sendable (inout Value) async throws -> T
) async rethrows -> T {
_ operation: @Sendable (inout Value) throws -> T
) rethrows -> T {
var value = self.value
defer { self.value = value }
return try await operation(&value)
return try operation(&value)
}

/// Overwrite the isolated value with a new value.
Expand Down
17 changes: 17 additions & 0 deletions Sources/ComposableArchitecture/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import Combine
import SwiftUI
import XCTestDynamicOverlay

// MARK: - Deprecated after 0.47.2

extension ActorIsolated {
@available(
*,
deprecated,
message: "Use the non-async version of 'withValue'."
)
public func withValue<T: Sendable>(
_ operation: @Sendable (inout Value) async throws -> T
) async rethrows -> T {
var value = self.value
defer { self.value = value }
return try await operation(&value)
}
}

// MARK: - Deprecated after 0.45.0:

@available(
Expand Down