You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**DI**: Instance-based ServiceLocator — no `.shared` singleton. `@Service` property wrapper resolves via `static subscript(_enclosingInstance:)` from the enclosing type's `serviceLocator` (requires `ServiceLocatorProvider` conformance). One `ServiceLocator()` created in SceneDelegate, threaded through coordinators → sessions → ViewModels.
62
+
-**DI**: Session-scoped ServiceLocator — no `.shared` singleton. Each `Session` creates and owns its own `ServiceLocator`. On session transition, the old ServiceLocator is released with the session (no stale services). `@Service` property wrapper resolves via `static subscript(_enclosingInstance:)` from the enclosing type's `serviceLocator` (requires `ServiceLocatorProvider` conformance). Coordinators and ViewModels receive the current session's ServiceLocator via constructor injection.
63
63
64
64
## Rule Index
65
65
Consult these files for detailed guidance (not auto-loaded — read on demand):
@@ -73,13 +73,13 @@ Consult these files for detailed guidance (not auto-loaded — read on demand):
73
73
- ViewModels use closures for navigation (no coordinator protocols)
74
74
- Navigation logic ONLY in Coordinators, never in Views
75
75
- Protocol placement: Core = reusable abstractions, Model = domain-specific
76
-
-Instance-based ServiceLocator with `@Service` property wrapper (`ServiceLocatorProvider` conformance)
76
+
-Session-scoped ServiceLocator with `@Service` property wrapper — ViewModels conform to `SessionProvider`, store `let session: Session`
77
77
- Combine over NotificationCenter for reactive state
78
78
79
79
## Testing
80
80
- Swift Testing framework (`import Testing`, `@Test`, `#expect`, `@Suite`)
81
-
- Each test creates its own `ServiceLocator()` instance — no `.serialized` needed, tests run in parallel
82
-
- Use `makeServiceLocator()` helper to create per-test locator with mocks, pass via `serviceLocator:` param
81
+
- Each test creates its own `MockSession` (from `FunModelTestSupport`) — no `.serialized` needed, tests run in parallel
82
+
- Use `makeSession()` helper to create per-test session with mocks via `MockSession(serviceLocator:)`, pass via `session:` param
83
83
- Consolidate thin init tests into a single test when they test the same concern
84
84
- Centralized mocks in `Model/Sources/ModelTestSupport/Mocks/`
0 commit comments