From a069c3b1b2f70bca267cb61895e0ea85a4dc9cbb Mon Sep 17 00:00:00 2001 From: John Hammerlund Date: Mon, 23 Dec 2019 15:17:15 -0800 Subject: [PATCH] Release 0.3.2 (#18) Includes documentation updates --- CHANGELOG.md | 12 ++++++++++++ README.md | 25 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2283b51..afe18d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,18 @@ - None +## 0.3.2 + +#### Enhancements +- Add `@Injectable` property wrapper + +#### Bug Fixes +- None + +#### Other +- None + + ## 0.3.1 #### Enhancements diff --git a/README.md b/README.md index edd3014..b1dea15 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ final class DefaultDependencyRegistry: DependencyRegistryType { } /// Recursive dependencies are lazily resolved DependencyContainer.global.register(MyViewControllerDataStoreType.self) { container in - MyViewControllerDataStore(backendService: container.resolve(MyBackendServiceType.self)) + MyViewControllerDataStore(backendService: container.resolve()) } /// etc. } @@ -134,6 +134,29 @@ final class SampleViewController { } ``` + +With Swift 5.1, Relay supports auto-injection via a custom [property wrapper](https://docs.swift.org/swift-book/LanguageGuide/Properties.html#ID617). This allows your interface to be more declarative and for dependency access semantics to be more prescriptive: + +```swift +final class MyDependentComponent { + + @Injected var foo: FooType + @Injected(scope: .custom) var bar: BarType + +} +``` + +This is equivalent to: + +```swift +final class MyDependentComponent { + + lazy var foo: FooType = DependencyContainer.global.resolve() + lazy var bar: BarType = DependencyContainer.container(for: .custom).resolve() + +} +``` + --- ## Dynamic Dependencies