TransactionObserver

public protocol TransactionObserver : class

A transaction observer is notified of all changes and transactions committed or rollbacked on a database.

Adopting types must be a class.

  • Filters database changes that should be notified the the databaseDidChange(with:) method.

    Declaration

    Swift

    func observes(eventsOfKind eventKind: DatabaseEventKind) -> Bool
  • Notifies a database change (insert, update, or delete).

    The change is pending until the end of the current transaction, notified to databaseWillCommit, databaseDidCommit and databaseDidRollback.

    This method is called on the database queue.

    The event is only valid for the duration of this method call. If you need to keep it longer, store a copy of its properties.

    Warning

    this method must not change the database.

    Declaration

    Swift

    func databaseDidChange(with event: DatabaseEvent)
  • When a transaction is about to be committed, the transaction observer has an opportunity to rollback pending changes by throwing an error.

    This method is called on the database queue.

    Warning

    this method must not change the database.

    Throws

    An eventual error that rollbacks pending changes.

    Declaration

    Swift

    func databaseWillCommit() throws
  • Database changes have been committed.

    This method is called on the database queue. It can change the database.

    Declaration

    Swift

    func databaseDidCommit(_ db: Database)
  • Database changes have been rollbacked.

    This method is called on the database queue. It can change the database.

    Declaration

    Swift

    func databaseDidRollback(_ db: Database)
  • Undocumented

    Declaration

    Swift

    public protocol TransactionObserver : class