Documentation

This commit is contained in:
Gwendal Roué committed 2018-12-07 08:36:11 +01:00
1 parent 815a3697da
commit 37983b8581
1 file changed
+4 -6
+4 -6
View File
@@ -6103,7 +6103,7 @@ struct HallOfFame {
}
}
let hallOfFame = try dbQueue.read { try HallOfFame.fetch($0) }
let hallOfFame = try dbQueue.read { db in try HallOfFame.fetch(db) }
print("""
Best players out of \(hallOfFame.totalPlayerCount):
\(hallOfFame.bestPlayers)
@@ -6118,11 +6118,9 @@ In order to track changes in the Hall of Fame, we'll use the `ValueObservation.t
In our case, any change to the `player` table can impact the Hall of Fame. We thus track the request for all players, `Player.all()`, and fetch a new Hall of Fame whenever players change:
```swift
let observation = ValueObservation.tracking(
Player.all(),
fetch: { db -> HallOfFame in
return HallOfFame.fetch(db)
})
let observation = ValueObservation.tracking(Player.all(), fetch: { db in
try HallOfFame.fetch(db)
})
let observer = observation.start(in: dbQueue) { hallOfFame: HallOfFame in
print("""