Skip to content

Commit 6366156

Browse files
authored
Add projected setter to @Fetch wrappers (#53)
1 parent bf54eb0 commit 6366156

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Sources/SharingGRDBCore/Fetch.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public struct Fetch<Value: Sendable>: Sendable {
3333
/// Useful if you want to access various property wrapper state, like ``loadError``,
3434
/// ``isLoading``, and ``publisher``.
3535
public var projectedValue: Self {
36-
self
36+
get { self }
37+
nonmutating set { sharedReader.projectedValue = newValue.sharedReader.projectedValue }
3738
}
3839

3940
/// Returns a ``sharedReader`` for the given key path.

Sources/SharingGRDBCore/FetchAll.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public struct FetchAll<Element: Sendable>: Sendable {
3333
/// Useful if you want to access various property wrapper state, like ``loadError``,
3434
/// ``isLoading``, and ``publisher``.
3535
public var projectedValue: Self {
36-
self
36+
get { self }
37+
nonmutating set { sharedReader.projectedValue = newValue.sharedReader.projectedValue }
3738
}
3839

3940
/// Returns a ``sharedReader`` for the given key path.

Sources/SharingGRDBCore/FetchOne.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public struct FetchOne<Value: Sendable>: Sendable {
3333
/// Useful if you want to access various property wrapper state, like ``loadError``,
3434
/// ``isLoading``, and ``publisher``.
3535
public var projectedValue: Self {
36-
self
36+
get { self }
37+
nonmutating set { sharedReader.projectedValue = newValue.sharedReader.projectedValue }
3738
}
3839

3940
/// Returns a ``sharedReader`` for the given key path.

0 commit comments

Comments
 (0)