From 68f4db468ab2e980efbbd0975d64aa117f5b5b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 11 Apr 2020 17:25:16 +0200 Subject: [PATCH] Documentation --- Documentation/GRDB5MigrationGuide.md | 10 +++++----- README.md | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Documentation/GRDB5MigrationGuide.md b/Documentation/GRDB5MigrationGuide.md index e33f03849..2e7eff3e8 100644 --- a/Documentation/GRDB5MigrationGuide.md +++ b/Documentation/GRDB5MigrationGuide.md @@ -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) ``` diff --git a/README.md b/README.md index a05928905..0ffacd042 100644 --- a/README.md +++ b/README.md @@ -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) ```