Remove old DI files from LuminateCore, add import LuminateDI to consumers
This commit is contained in:
parent
b12352c29d
commit
0ecb95d7c8
6 changed files with 3 additions and 62 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import Adwaita
|
||||
import Foundation
|
||||
import LuminateCore
|
||||
import LuminateDI
|
||||
import LuminateHome
|
||||
import LuminateLibrary
|
||||
import LuminatePlayer
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
public final class DIContainer {
|
||||
|
||||
public static let shared = DIContainer()
|
||||
public private(set) var values = InjectionValues()
|
||||
|
||||
private init() {}
|
||||
|
||||
public func register<T>(
|
||||
_ keyPath: WritableKeyPath<InjectionValues, T?>,
|
||||
value: T
|
||||
) {
|
||||
values[keyPath: keyPath] = value
|
||||
}
|
||||
|
||||
public func resolve<T>(
|
||||
_ keyPath: KeyPath<InjectionValues, T?>
|
||||
) -> T {
|
||||
guard let value = values[keyPath: keyPath] else {
|
||||
fatalError(
|
||||
"DIContainer: No value registered for \(keyPath). "
|
||||
+ "Call DIContainer.shared.register(\\.key, value:) during app startup."
|
||||
)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
public func reset() {
|
||||
values = InjectionValues()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
@propertyWrapper
|
||||
public struct Injected<T> {
|
||||
|
||||
private let keyPath: KeyPath<InjectionValues, T?>
|
||||
|
||||
public var wrappedValue: T {
|
||||
DIContainer.shared.resolve(keyPath)
|
||||
}
|
||||
|
||||
public init(_ keyPath: KeyPath<InjectionValues, T?>) {
|
||||
self.keyPath = keyPath
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
import Foundation
|
||||
|
||||
public struct InjectionValues {
|
||||
|
||||
public var client: JellyfinClient?
|
||||
public var userId: String?
|
||||
public var imageService: ImageService?
|
||||
public var webSocketClient: WebSocketClient?
|
||||
public var persistence: PersistenceService?
|
||||
|
||||
public init() {}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import Adwaita
|
||||
import Foundation
|
||||
import LuminateCore
|
||||
import LuminateDI
|
||||
|
||||
struct HomePosterCell: View {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import Adwaita
|
||||
import LuminateCore
|
||||
import LuminateDI
|
||||
|
||||
public struct HomeView: View {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue