30 lines
606 B
Swift

//
// Dependency.swift
// DependencyInjection
//
// Created by Javier Cicchelli on 05/12/2022.
// Copyright © 2022 Röck+Cöde. All rights reserved.
//
@propertyWrapper
public struct Dependency<D> {
// MARK: Properties
private let keyPath: WritableKeyPath<DependencyStore, D>
// MARK: Computed
public var wrappedValue: D {
get { DependencyStore[keyPath] }
set { DependencyStore[keyPath] = newValue }
}
// MARK: Initialisers
public init(_ keyPath: WritableKeyPath<DependencyStore, D>) {
self.keyPath = keyPath
}
}