-
-
Notifications
You must be signed in to change notification settings - Fork 161
Open
Description
I want to force one of my dependency to be resolved on background thread. Because it is a @ModelActor, which thread it is created will determine which thread it will execute the DB operations. Since I want the DB operations to always execute on the BG thread, so I want to create the Model Actor on the background thread as well.
Here's my code:
import Foundation
import Factory
@ModelActor
actor DatabaseManager {
@Injected(\.errorLogger) private var errorLogger
private var modelContext: ModelContext {
modelExecutor.modelContext
}
}
extension Container {
var databaseManager: Factory<DatabaseManager> {
self {
DatabaseManager(modelContainer: self.modelContainer.resolve())
}.singleton
}
}
Would appreciate your help, thanks!
Metadata
Metadata
Assignees
Labels
No labels