You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
publicstaticfuncresolve<Service>(_type: Service.Type= Service.self, name: String?=nil, args: Any?=nil) -> Service {
50
55
return root.resolve(type, name: name, args: args)
51
56
}
@@ -172,3 +177,27 @@ Returning, we switch back and the app again behaves normally.
172
177
173
178
Nice party trick, don't you think?
174
179
180
+
## Child Containers
181
+
182
+
Resolver 1.4.3 adds support for multiple child containers.
183
+
184
+
As stated above, you can put thousands of registrations into a single container but, should you desire to do so, you can now segment your registrations into smaller groups of containiners and then add each subcontainer to the main container.
185
+
186
+
Consider...
187
+
188
+
```
189
+
extension Resolver {
190
+
static let containerA = Resolver()
191
+
static let containerB = Resolver()
192
+
193
+
static func registerAllServices() {
194
+
main.add(child: containerA)
195
+
main.add(child: containerB)
196
+
...
197
+
}
198
+
}
199
+
```
200
+
201
+
Now when main is asked to resolve a given service, it will first search its own registrations and then, if not found, will search each of the included child containers to see if one of them contains the needed registration. First match will return, and containers will be searched in the order in which they're added.
202
+
203
+
This is basically a small change that reworks the "parent" mechanism to support multiple children. Parent (or "nested") containers still work as before.
Copy file name to clipboardExpand all lines: Documentation/Registration.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Introduction
4
4
5
-
As mention in the introduction, in order for Resolve to *resolve* a request for a paticular service you first need to register a factory that knows how to instantiate an instance of the service.
5
+
As mentioned in the introduction, in order for Resolve to *resolve* a request for a paticular service you first need to register a factory that knows how to instantiate an instance of the service.
6
6
7
7
```swift
8
8
Resolver.register { NetworkService() }
@@ -28,7 +28,7 @@ Let's start by adding the master injection file for the entire application.
28
28
Add a file named `AppDelegate+Injection.swift` to your project and add the following code:
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,11 +127,13 @@ Resolver is available under the MIT license. See the LICENSE file for more info.
127
127
128
128
## Additional Resouces
129
129
130
+
*[Resolver for iOS Dependency Injection: Getting Started | Ray Wenderlich](https://www.raywenderlich.com/22203552-resolver-for-ios-dependency-injection-getting-started)
*[Swift 5.1 Takes Dependency Injection to the Next Level](https://medium.com/better-programming/taking-swift-dependency-injection-to-the-next-level-b71114c6a9c6)
0 commit comments