diff options
Diffstat (limited to 'iosApp/iosApp/Shared/Inject.swift')
-rw-r--r-- | iosApp/iosApp/Shared/Inject.swift | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/iosApp/iosApp/Shared/Inject.swift b/iosApp/iosApp/Shared/Inject.swift new file mode 100644 index 0000000..0aaa388 --- /dev/null +++ b/iosApp/iosApp/Shared/Inject.swift @@ -0,0 +1,25 @@ +// +// Inject.swift +// iosApp +// +// Created by Iván on 26/01/22. +// Copyright © 2022 orgName. All rights reserved. +// + +import Foundation +import shared + +// Source: https://www.kiloloco.com/articles/004-dependency-injection-via-property-wrappers/ +// Source: https://medium.com/swlh/c1f02f06cd51 +@propertyWrapper +struct Inject<T: Injectable> { + var injectable: T + + init() { + injectable = Resolver.shared.resolve() + } + + public var wrappedValue: T { + get { return injectable } + } +} |