Skip to content

Commit 7461262

Browse files
authored
Allow values to be returned from withLock (#3154)
1 parent fea248b commit 7461262

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/ComposableArchitecture/SharedState/Shared.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public struct Shared<Value> {
6767
}
6868

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

7474
/// The underlying value referenced by the shared variable.

0 commit comments

Comments
 (0)