Last active
April 13, 2020 15:05
-
-
Save robertofrontado/96b4ba23b7f9e6b3317a9cbce9108982 to your computer and use it in GitHub Desktop.
SwiftDI - Injected With Caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
@propertyWrapper | |
public struct Injected<Value> { | |
private var value: Value? | |
public var wrappedValue: Value { | |
get { | |
return value ?? SwiftDI.default.resolve() | |
} | |
set { | |
value = newValue | |
} | |
} | |
public init() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment