Dependency Injection
PrismContainer is an actor-based IoC container that manages service lifetimes — singletons shared across the app, transient instances created fresh each time, and scoped instances tied to a request.
Registering Services
Register Services
Resolving Services
Resolve by Type
Service Lifetimes
Request-Scoped Services
Create a scope per request for services that should be unique to each request but shared within it:Scoped Resolution
Using in Route Handlers
SinceuserInfo is [String: String], you can’t store the container in the request. Instead, capture it in route closures:
Container in Routes
Error Handling
Handle Missing Services
Singletons can only be resolved from
PrismContainer, not from PrismScope. If you try to resolve a singleton from a scope, it throws .resolutionFailed. This prevents accidental lifecycle mismatches.