Keep An Observable Store From Invalidating Every Row

A reading list has a sync progress value, a collection of articles, and a read flag for each article. Updating progress should not make every row depend on that progress. Moving all three concepts into one object does not automatically create that dependency, but reading them together can.

With Observation, the useful question is precise: which properties did this view read while building its body?

Let each row read its own model

Apple’s model-data guide describes SwiftUI’s property-access tracking for observable models. This example keeps list membership on the store and row presentation on individual objects:

import Foundation
import Observation
import SwiftUI

@MainActor
@Observable
final class ReadingRow: Identifiable {
    let id: UUID
    var title: String
    var isRead = false
    init(id: UUID = UUID(), title: String) {
        self.id = id
        self.title = title
    }
}
@MainActor
@Observable
final class ReadingStore {
    var rows: [ReadingRow] = []
    var syncProgress = 0.0
}
struct ReadingList: View {
    let store: ReadingStore
    var body: some View {
        List(store.rows) { row in ReadingRowView(row: row) }
    }
}
struct ReadingRowView: View {
    let row: ReadingRow
    var body: some View {
        HStack {
            Text(row.title)
            if row.isRead { Image(systemName: "checkmark") }
        }
    }
}

ReadingList reads store.rows. ReadingRowView reads the title and read state of its row. Neither body reads syncProgress. A separate progress view can read that property where it belongs.

The models are main-actor isolated because this example is UI state. Observation tracks changes; it does not replace a concurrency policy for mutable reference types.

A computed property can widen the dependency

Suppose the parent computes store.rows.filter { !$0.isRead } while building its body. That calculation reads every row’s read flag. Changing one flag can correctly invalidate the parent’s filtered result because membership may have changed.

That is not a failure of Observation. The parent asked a question whose answer depends on every flag.

Decide where the computation belongs based on semantics. If the screen really displays only unread articles, that dependency is necessary. If it displays every article and merely paints a checkmark, filtering in the parent creates extra work for no product reason.

The same applies to a summary such as rows.filter(\.isRead).count. Keep that summary in a small view if it does not affect list structure. Do not add a stored counter solely to avoid a cheap local calculation until profiling justifies the extra consistency burden.

Reference rows and value rows have different boundaries

Here, editing a ReadingRow does not replace the rows array. Appending, removing, or reordering rows changes collection membership and can invalidate the list’s collection read.

If rows are value types stored directly in one observable array, mutating an element involves that observed array property. That design can still be completely appropriate. Do not switch a simple value model to reference semantics just to chase a theoretical body-count reduction.

Choose based on identity, editing ownership, and measured work. Stable IDs are still essential, and replacing every row object on each refresh can discard the finer identity you intended to preserve.

Test access dependencies below the renderer

The companion uses withObservationTracking to read the first row’s title and read flag. Changing the second row or sync progress does not trigger that tracked dependency; changing the first row’s read flag does.

A separate tracking scope reads only store.rows. Editing a row’s title leaves that collection read alone, while appending a row triggers it. Each assertion starts with a fresh tracking scope rather than treating the basic callback as a permanent subscription.

These are tests of observed property access. They are not promises about an exact number of SwiftUI body evaluations, rendered frames, or platform-internal diffing operations.

Measure the expensive part

Use Instruments to identify whether the problem is parent filtering, row body construction, image decoding, layout, or another dependency. A body running again can be inexpensive; an expensive calculation hidden inside a computed property is often the more useful target.

Keep this example small until the trace says otherwise. Adding equality wrappers, copied caches, and manual invalidation to every row can make correctness harder without improving the interaction the user noticed.

September 2026 review: property-tracking assertions passed with the Observation macro compiler, and the complete SwiftUI example type-checked for iOS 17. No frame-rate or rendered-body-count result is claimed.