Documentation

This commit is contained in:
Gwendal Roué committed 2020-04-11 17:25:16 +02:00
1 parent 62dbc78090
commit 68f4db468a
2 files changed
+12 -8

No files matched your search

+5 -5
View File
@@ -45,7 +45,7 @@ In the end, this migration step might require some work. But it's for the benefi
### Creating ValueObservation
In GRDB 5, you *always* create a ValueObservation by providing a function thats fetches the observed value:
In GRDB 5, you *always* create a ValueObservation by providing a function that fetches the observed value:
```swift
// GRDB 5
@@ -53,12 +53,12 @@ let observation = ValueObservation.tracking { db in
/* fetch and return the observed value */
}
// An example: observing all players
let observation = ValueObservation.tracking { db -> [Player] in
return try Player.fetchAll(db)
// For example, an observation of [Player], which tracks all players:
let observation = ValueObservation.tracking { db in
try Player.fetchAll(db)
}
// The same example, using short notation
// The same observation, using shorthand notation:
let observation = ValueObservation.tracking(Player.fetchAll)
```
+7 -3
View File
@@ -5500,15 +5500,19 @@ Tracked changes include changes performed by the [query interface](#the-query-in
ValueObservation does not notify changes performed by external connections.
2. Define a ValueObservation which tracks the values you are interested in.
2. Define a ValueObservation by providing a function that fetches the observed value.
```swift
// An observation of [Player] which tracks all players:
let observation = ValueObservation.tracking { db in
/* fetch and return the observed value */
}
// For example, an observation of [Player], which tracks all players:
let observation = ValueObservation.tracking { db in
try Player.fetchAll(db)
}
// The same observation, with short-hand notation:
// The same observation, using shorthand notation:
let observation = ValueObservation.tracking(Player.fetchAll)
```