Skip to content

Instantly share code, notes, and snippets.

@robertofrontado
Last active April 13, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertofrontado/96b4ba23b7f9e6b3317a9cbce9108982 to your computer and use it in GitHub Desktop.
Save robertofrontado/96b4ba23b7f9e6b3317a9cbce9108982 to your computer and use it in GitHub Desktop.
SwiftDI - Injected With Caching
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