---
title: "init(historyTokens:observedModels:authors:modelContainer:isolation:)"
framework: swiftdata
role: symbol
role_heading: Initializer
path: "swiftdata/historyobserver/init(historytokens:observedmodels:authors:modelcontainer:isolation:)"
---

# init(historyTokens:observedModels:authors:modelContainer:isolation:)

Creates a history observer that reports changes through its observable eventCounter property.

## Declaration

```swift
convenience init(historyTokens: [String : any HistoryToken]? = nil, observedModels: [any PersistentModel.Type] = [], authors: Set<String> = [], modelContainer: ModelContainer, isolation: isolated (any Actor)? = #isolation) throws
```

## Parameters

- `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

Discussion Use this initializer when you want to observe history changes via SwiftUI’s observation system or by reading eventCounter directly. note: An error if the observer fails to fetch the initial history tokens.
