init(historyTokens:observedModels:authors:modelContainer:isolation:)
Creates a history observer that reports changes through its observable Eventcounter property.
Declaration
convenience init(historyTokens: [String : any HistoryToken]? = nil, observedModels: [any PersistentModel.Type] = [], authors: Set<String> = [], modelContainer: ModelContainer, isolation: isolated (any Actor)? = #isolation) throwsParameters
- historyTokens:
The initial history tokens keyed by store identifier. When
nil, the observer starts with an empty token set and captures tokens from the first notification for each store. - observedModels:
The model types to filter for. When empty (the default), the observer responds to changes for any model.
- authors:
The transaction authors to filter for. When empty (the default), the observer responds to changes from any author.
- modelContainer:
The model container to observe.
Discussion
Use this initializer when you want to observe history changes via SwiftUI’s observation system or by reading eventCounter directly.