Advanced Features
PrismArchitecture ships with several advanced tools for debugging, persistence, and testing.State Persistence
Persist state across app launches usingPrismPersistenceStrategy. Three built-in strategies are provided:
Disk Persistence
Saves state as JSON files to the Documents directory:Disk Persistence
UserDefaults Persistence
Stores state in UserDefaults for lightweight data:UserDefaults Persistence
Keychain Persistence
Stores sensitive state in the system Keychain:Keychain Persistence
Custom Strategy
ImplementPrismPersistenceStrategy for any backend:
Custom Persistence
Time-Travel Debugger
PrismTimeTravelDebugger records state snapshots at every action, letting you navigate through your app’s history:
Time Travel Setup
Inspecting Snapshots
Each snapshot captures the state, action description, timestamp, and position:Snapshot Inspection
Undo / Redo
PrismUndoRedoStack provides a classic undo/redo mechanism:
Undo / Redo
Derived Store
PrismDerivedStore provides a read-only view into a parent store that only notifies when the derived value actually changes:
Derived Store
PrismDerivedStore uses Equatable on the local state to avoid unnecessary SwiftUI re-renders.
Testing with PrismTestStore
PrismTestStore wraps PrismStore with testing utilities for deterministic assertions:
PrismTestStore
Testing Async Effects
UsewaitForEffects() to wait for in-flight effects to complete before asserting:
Testing Effects
Testing with Middleware
Testing Middleware