Add @Injected property wrapper
This commit is contained in:
parent
e829b8141b
commit
44b5a02ab6
1 changed files with 17 additions and 0 deletions
17
Sources/LuminateCore/Injected.swift
Normal file
17
Sources/LuminateCore/Injected.swift
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Foundation
|
||||
|
||||
@propertyWrapper
|
||||
public struct Injected<T> {
|
||||
|
||||
private let keyPath: KeyPath<InjectionValues, T?>
|
||||
|
||||
@MainActor
|
||||
public var wrappedValue: T {
|
||||
DIContainer.shared.resolve(keyPath)
|
||||
}
|
||||
|
||||
public init(_ keyPath: KeyPath<InjectionValues, T?>) {
|
||||
self.keyPath = keyPath
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue