Skip to content

Commit

Permalink
Fix dynamic queries example (#14)
Browse files Browse the repository at this point in the history
* Fix dynamic queries example

* Update Sources/SharingGRDB/Documentation.docc/Articles/DynamicQueries.md

* Update Sources/SharingGRDB/Documentation.docc/Articles/DynamicQueries.md

---------

Co-authored-by: Stephen Celis <[email protected]>
  • Loading branch information
andtie and stephencelis authored Feb 17, 2025
1 parent 1f1da39 commit 15b5bd3
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ struct ContentView: View {
List {
// ...
}
.onChange(of: [filterDate, order] as [AnyHashable], initial: true) {
updateQuery()
.task(id: [filter, ordering] as [AnyHashable]) {
await updateQuery()
}
}

private func updateQuery() {
$items.load(.fetch(Items(filterDate: filterDate, order: order)))
private func updateQuery() async {
do {
try await $items.load(.fetch(Items(filterDate: filterDate, order: order)))
} catch {
// Handle error...
}
}

private struct Items: FetchKeyRequest {
Expand Down

0 comments on commit 15b5bd3

Please sign in to comment.