Skip to content

Commit

Permalink
feat: DI is aware of context that starts it
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Feb 26, 2024
1 parent 01bb3b5 commit d2573fa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion kDrive/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import VersionChecker
@main
final class AppDelegate: UIResponder, UIApplicationDelegate, AccountManagerDelegate {
/// Making sure the DI is registered at a very early stage of the app launch.
private let dependencyInjectionHook = EarlyDIHook()
private let dependencyInjectionHook = EarlyDIHook(context: .app)

private var reachabilityListener: ReachabilityListener!
private static let currentStateVersion = 4
Expand Down
11 changes: 10 additions & 1 deletion kDrive/Utils/AppFactoryService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,24 @@ import InfomaniakDI
import kDriveCore
import os.log

public enum AppContext {
case app
case actionExtension
case fileProviderExtension
case shareExtension
}

/// Something that loads the DI on init
public struct EarlyDIHook {
public init() {
public init(context: AppContext) {
// setup DI ASAP

let navigationManagerFactory = Factory(type: NavigationManageable.self) { _, _ in
NavigationManager()
}

// TODO: Insert context in dedicated DI object

os_log("EarlyDIHook")
FactoryService.setupDependencyInjection(other: [navigationManagerFactory])
}
Expand Down
2 changes: 1 addition & 1 deletion kDriveActionExtension/ActionNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import VersionChecker

final class ActionNavigationController: TitleSizeAdjustingNavigationController {
/// Making sure the DI is registered at a very early stage of the app launch.
private let dependencyInjectionHook = EarlyDIHook()
private let dependencyInjectionHook = EarlyDIHook(context: .actionExtension)

@LazyInjectService var accountManager: AccountManageable

Expand Down
2 changes: 1 addition & 1 deletion kDriveFileProvider/FileProviderExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import RealmSwift

final class FileProviderExtension: NSFileProviderExtension {
/// Making sure the DI is registered at a very early stage of the app launch.
private let dependencyInjectionHook = EarlyDIHook()
private let dependencyInjectionHook = EarlyDIHook(context: .fileProviderExtension)

/// Something to enqueue async await tasks in a serial manner.
let asyncAwaitQueue = TaskQueue()
Expand Down
2 changes: 1 addition & 1 deletion kDriveShareExtension/ShareNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import VersionChecker

final class ShareNavigationViewController: TitleSizeAdjustingNavigationController {
/// Making sure the DI is registered at a very early stage of the app launch.
private let dependencyInjectionHook = EarlyDIHook()
private let dependencyInjectionHook = EarlyDIHook(context: .shareExtension)

@LazyInjectService var accountManager: AccountManageable

Expand Down

0 comments on commit d2573fa

Please sign in to comment.