We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AppDelegate:
import Foundation import RouterService import RouterServiceInterface import CoreData extension AppDelegate { func registerDependencies() { routerService.register(dependencyFactory: { AppDelegate.shared.persistentContainer.viewContext }, forType: NSManagedObjectContext.self) } }
import RouterService import RouterServiceInterface @main class AppDelegate: UIResponder, UIApplicationDelegate { static let shared = UIApplication.shared.delegate as? AppDelegate ?? AppDelegate() private(set) var persistentContainer = myContainer let routerService = RouterService() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { createPersistentStoreContainer { container in self.persistentContainer = container } ... // Register Dependencies registerDependencies() return true }
Usage:
import CoreData import RouterServiceInterface final class ProfileDashboardViewModel { // MARK: - Properties let navigationLeftIconResource: ImageName let title: String let employeeID: String let employeeName: String lazy private(set) var employeeProfile: EmployeeProfile = { if let profile = EmployeeProfile.fetch(for: self.employeeID, in: self.managedObjectContext) { return profile } let employeeProfile = EmployeeProfile(context: managedObjectContext) employeeProfile.employeeID = self.employeeID employeeProfile.name = self.employeeName return employeeProfile }() @Dependency var managedObjectContext: NSManagedObjectContext
Here getting the following error: Fatal error: Attempted to use Dependency without resolving it first!
Also when I put a breakpoint inside the register(dependencyFactory: {} closure it never hits the breakpoint.
register(dependencyFactory: {}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
AppDelegate:
Usage:
Here getting the following error:
Fatal error: Attempted to use Dependency without resolving it first!
Also when I put a breakpoint inside the
register(dependencyFactory: {}
closure it never hits the breakpoint.The text was updated successfully, but these errors were encountered: