Instance Methodgrdb 7.3.0GRDB

add(transactionObserver:extent:)

Adds a transaction observer on the database connection, so that it gets notified of database changes and transactions.

TransactionObserver.swift:32
func add(transactionObserver: some TransactionObserver, extent: TransactionObservationExtent = .observerLifetime)

Parameters

transactionObserver

A transaction observer.

extent

The duration of the observation. The default is the observer lifetime (observation lasts until observer is deallocated).

This method has no effect on read-only database connections.

For example:

let myObserver = MyObserver()
try dbQueue.write { db in
    db.add(transactionObserver: myObserver)
}