Skip to content

Commit

Permalink
Allow values to be returned from withLock (#3154)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis authored Jun 7, 2024
1 parent fea248b commit 7461262
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/ComposableArchitecture/SharedState/Shared.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public struct Shared<Value> {
}

/// Perform an operation on shared state with isolated access to the underlying value.
public func withLock(_ transform: @Sendable (inout Value) -> Void) {
transform(&self._wrappedValue)
public func withLock<R>(_ transform: @Sendable (inout Value) throws -> R) rethrows -> R {
try transform(&self._wrappedValue)
}

/// The underlying value referenced by the shared variable.
Expand Down

0 comments on commit 7461262

Please sign in to comment.