mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
Database.afterNextTransactionCommit(_:): document that the closure runs in a protected dispatch queue
This commit is contained in:
1 parent
da48b0880e
commit
66c2b72a28
1 file changed
+4
-2
@@ -4074,9 +4074,9 @@ Database observation requires that a single [database queue](#database-queues) o
|
||||
|
||||
### After Commit Hook
|
||||
|
||||
**When an application needs to make sure a database transaction has been successfully committed before it executes some work, use the `Database.afterNextTransactionCommit(_:)` method.**
|
||||
**When your application needs to make sure a database transaction has been successfully committed before it executes some work, use the `Database.afterNextTransactionCommit(_:)` method.**
|
||||
|
||||
Its closure argument is called after database changes have been successfully written to disk:
|
||||
Its closure argument is called right after database changes have been successfully written to disk:
|
||||
|
||||
```swift
|
||||
dbQueue.inTransaction { db in
|
||||
@@ -4088,6 +4088,8 @@ dbQueue.inTransaction { db in
|
||||
}
|
||||
```
|
||||
|
||||
The closure runs in a protected dispatch queue, serialized with all database updates.
|
||||
|
||||
**This "after commit hook" helps synchronizing the database with other resources, such as files, or system sensors.**
|
||||
|
||||
In the example below, a [location manager](https://developer.apple.com/documentation/corelocation/cllocationmanager) starts monitoring a CLRegion if and only if it has successfully been stored in the database:
|
||||
|
||||
Reference in new issue
Block a user