What problem does it solve?
The actor-based repository pattern prevents data races and simplifies concurrent access to shared mutable state in Swift applications by combining an in-memory cache with atomic file-backed persistence.
Core Features & Use Cases
- Actor isolation for thread safety: serialized access enforced by the compiler removes the need for manual locks or dispatch queues.
- In-memory cache with durable persistence: fast O(1) reads from cache and atomic writes to disk for reliable local storage and offline-first scenarios.
- Generic Codable & Identifiable models: reusable repository across domain types and easy integration with reactive ViewModels.
- Use case: maintain a local store of app data (e.g., questions, settings, cached content), update from UI via an @Observable ViewModel, and persist changes reliably across app restarts.
Quick Start
Use the swift-actor-persistence skill to instantiate a LocalRepository for your Codable Identifiable model, load all items, and save or delete entries while relying on actor isolation for thread safety.