Skip to content

Cache view context instance per store#28

Merged
colemancda merged 2 commits into
masterfrom
feature/cached-view-context
Jul 23, 2026
Merged

Cache view context instance per store#28
colemancda merged 2 commits into
masterfrom
feature/cached-view-context

Conversation

@colemancda

Copy link
Copy Markdown
Member

Follow-up to #27.

InMemoryModelStorage.viewContext now returns a single cached InMemoryViewContext instance per store instead of constructing a fresh one on every access, matching the caching pattern used by NSPersistentContainer.viewContext. The cache uses a nonisolated(unsafe) property populated lazily from the @MainActor getter, so all access is main-actor confined. Guarded out under Embedded Swift.

testSharedDataWithStore additionally asserts context === store.viewContext.

@colemancda
colemancda merged commit 9509738 into master Jul 23, 2026
28 of 32 checks passed
@colemancda
colemancda deleted the feature/cached-view-context branch July 23, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant