Skip to content

Instantly share code, notes, and snippets.

@fmo91
Created November 4, 2019 04: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 fmo91/2e292c4e8813ccca7bccedd5a916ae82 to your computer and use it in GitHub Desktop.
Save fmo91/2e292c4e8813ccca7bccedd5a916ae82 to your computer and use it in GitHub Desktop.
enum Dependencies {
// ...
@propertyWrapper
struct Inject<T> {
private let dependencyName: Name
private let container: Container
var wrappedValue: T {
get { container.resolve(dependencyName) }
}
init(_ dependencyName: Name = .default, on container: Container = .default) {
self.dependencyName = dependencyName
self.container = container
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment