mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Documentation
This commit is contained in:
1 parent
d53412d404
commit
1867ee91de
2 files changed
+5
-6
No files matched your search
+1
-3
@@ -3,9 +3,7 @@ Release Notes
|
||||
|
||||
## Next Version
|
||||
|
||||
This release comes with **ValueObservation**, a new type which can track the results of database requests, and notifies fresh values each time the database changes.
|
||||
|
||||
ValueObservation provides convenient APIs for applications:
|
||||
This release comes with **[ValueObservation](README.md#valueobservation)**, a new type which tracks the results of database requests, and notifies fresh values whenever the database changes:
|
||||
|
||||
```swift
|
||||
let observer = ValueObversation
|
||||
|
||||
@@ -6192,9 +6192,9 @@ protocol TransactionObserverType : class {
|
||||
|
||||
## ValueObservation
|
||||
|
||||
**ValueObservation automatically tracks changes in the results of a [request](#requests).**
|
||||
**ValueObservation tracks changes in the results of database [requests](#requests), and notifies fresh values whenever the database changes.**
|
||||
|
||||
It is designed for easy consumption of fresh values by an application. For example, you will find below a typical UIViewController setup:
|
||||
For example, here is a typical UIViewController which observes the database in order to keep its view up-to-date:
|
||||
|
||||
```swift
|
||||
class PlayerViewController: UIViewController {
|
||||
@@ -6204,7 +6204,7 @@ class PlayerViewController: UIViewController {
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
// Define a ValueObservation that tracks a request
|
||||
// Define a ValueObservation which tracks a player
|
||||
let request = Player.filter(key: 42)
|
||||
let observation = ValueObservation.trackingOne(request)
|
||||
|
||||
@@ -6212,6 +6212,7 @@ class PlayerViewController: UIViewController {
|
||||
observer = try! observation.start(
|
||||
in: dbQueue,
|
||||
onChange: { [unowned self] player: Player? in
|
||||
// Player has changed: update view
|
||||
self.nameLabel.text = player?.name
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user