Conversation
Refactor observation tracking to use checked continuation for better control of async flow.
Template encourages one-shot assignmentThe func onAppear() async {
items = dataCache.value.items }This is a one-time copy. If a modal adds/modifies an item in the cache, the original screen won't reflect the change. Computed properties should be the primary pattern var items: [Item] { dataCache.value.items }
Suggestion: The template and Documentation hierarchy for observation patternsThe documentation covers three observation approaches but could benefit from a clearer hierarchy with concrete use cases:
Populate breaking changeT.Element now requires Identifiable (was just Equatable), and merging is now ID-based (update in-place + append). Better behavior, but this is a breaking change worth calling out in the PR description. |
|
@ssestak I updated the template and docs. I'll also mention breaking changes in release notes. |
The base branch was changed.
Data cache on main actor -> prevent actor hops when reading/writing the changes from main actor
@samoilyk @bezoadam 👇 (part of Documentation.md)
Observation granularity:
@Observabletracks at the stored property level.DataCachehas one stored property —value. All computed properties that readdataCache.value(regardless of which sub-property) re-evaluate when any part of the model changes. For SwiftUI views this is fine — body re-evaluation is cheap and SwiftUI diffs the output. For imperative subscriptions, add manual deduplication or useObservations+.removeDuplicates()on iOS 26+.