From 3eef73d49db2947098a0279573b0b48749035744 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Tue, 11 Apr 2023 02:01:42 +0200 Subject: [PATCH] Implemented the DependencyService service. --- .../Services/DependencyService.swift | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Apps/Locations/Libraries/Sources/Dependency/Services/DependencyService.swift diff --git a/Apps/Locations/Libraries/Sources/Dependency/Services/DependencyService.swift b/Apps/Locations/Libraries/Sources/Dependency/Services/DependencyService.swift new file mode 100644 index 0000000..3716c42 --- /dev/null +++ b/Apps/Locations/Libraries/Sources/Dependency/Services/DependencyService.swift @@ -0,0 +1,28 @@ +// +// DependencyService.swift +// Dependency +// +// Created by Javier Cicchelli on 11/04/2023. +// Copyright © 2023 Röck+Cöde. All rights reserved. +// + +/// This service provide write/read access to the injected dependencies. +public struct DependencyService { + + // MARK: Properties + + private static var current = DependencyService() + + // MARK: Subscripts + + public static subscript(key: DK.Type) -> DK.Value { + get { key.currentValue } + set { key.currentValue = newValue } + } + + public static subscript(_ keyPath: WritableKeyPath) -> D { + get { current[keyPath: keyPath] } + set { current[keyPath: keyPath] = newValue } + } + +}