Skip to content

Commit 15b5bd3

Browse files
andtiestephencelis
andauthored
Fix dynamic queries example (#14)
* 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 <stephen.celis@gmail.com>
1 parent 1f1da39 commit 15b5bd3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ struct ContentView: View {
5757
List {
5858
// ...
5959
}
60-
.onChange(of: [filterDate, order] as [AnyHashable], initial: true) {
61-
updateQuery()
60+
.task(id: [filter, ordering] as [AnyHashable]) {
61+
await updateQuery()
6262
}
6363
}
6464

65-
private func updateQuery() {
66-
$items.load(.fetch(Items(filterDate: filterDate, order: order)))
65+
private func updateQuery() async {
66+
do {
67+
try await $items.load(.fetch(Items(filterDate: filterDate, order: order)))
68+
} catch {
69+
// Handle error...
70+
}
6771
}
6872

6973
private struct Items: FetchKeyRequest {

0 commit comments

Comments
 (0)