Skip to content

Commit

Permalink
Merge branch 'master' into add-language-identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlongco authored Sep 6, 2021
2 parents 69d095e + 99ae25a commit 653db1b
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 135 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Resolver Changelog

### 1.4.4

* Reduced code size and improved performance
* Update registration cache key mechanism to prevent possible registration overwrites

### 1.4.3

* Add capability for multiple child containers

### 1.4.2

* Fix threading issue in LazyInjected and WeakLazyInjected property wrappers
* Fix argument passing in .implements
* Update projct for Xcode 12.5
* Update Swift class deprecation

### 1.4.1

* Fix bug forwarding new argument structure from factory to factory - PR#89
Expand Down
31 changes: 30 additions & 1 deletion Documentation/Containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ extension Resolver: ResolverRegistering {
}
```

The static register and resolve functions simply pass the buck to main and root, respectively.
The static (class) register and resolve functions simply pass the buck to main and root, respectively.

```swift
public static func register<Service>(_ type: Service.Type = Service.self, name: Resolver.Name? = nil,
factory: @escaping ResolverFactoryArgumentsN<Service>) -> ResolverOptions<Service> {
return main.register(type, name: name, factory: factory)
}

public static func resolve<Service>(_ type: Service.Type = Service.self, name: String? = nil, args: Any? = nil) -> Service {
return root.resolve(type, name: name, args: args)
}
Expand Down Expand Up @@ -172,3 +177,27 @@ Returning, we switch back and the app again behaves normally.

Nice party trick, don't you think?

## Child Containers

Resolver 1.4.3 adds support for multiple child containers.

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.

Consider...

```
extension Resolver {
static let containerA = Resolver()
static let containerB = Resolver()
static func registerAllServices() {
main.add(child: containerA)
main.add(child: containerB)
...
}
}
```

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.

This is basically a small change that reworks the "parent" mechanism to support multiple children. Parent (or "nested") containers still work as before.
2 changes: 1 addition & 1 deletion Documentation/Cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Note in particular the additional parameters needed to create a `XYZViewModel` a

## The Process

Let's kick things off by given a view controller its view model.
Let's kick things off by giving a view controller its view model.

```swift
class MyViewController: UIViewController {
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

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.
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.

```swift
Resolver.register { NetworkService() }
Expand All @@ -28,7 +28,7 @@ Let's start by adding the master injection file for the entire application.
Add a file named `AppDelegate+Injection.swift` to your project and add the following code:

```swift
#import Resolver
import Resolver

extension Resolver: ResolverRegistering {
public static func registerAllServices() {
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ Resolver is available under the MIT license. See the LICENSE file for more info.

## Additional Resouces

* [Resolver for iOS Dependency Injection: Getting Started | Ray Wenderlich](https://www.raywenderlich.com/22203552-resolver-for-ios-dependency-injection-getting-started)
* [API Documentation](./Documentation/API/Classes/Resolver.html)
* [Inversion of Control Design Pattern ~ Wikipedia](https://en.wikipedia.org/wiki/Inversion_of_control)
* [Inversion of Control Containers and the Dependency Injection pattern ~ Martin Fowler](https://martinfowler.com/articles/injection.html)
* [Nuts and Bolts of Dependency Injection in Swift](https://cocoacasts.com/nuts-and-bolts-of-dependency-injection-in-swift/)\
* [Nuts and Bolts of Dependency Injection in Swift](https://cocoacasts.com/nuts-and-bolts-of-dependency-injection-in-swift/)
* [Dependency Injection in Swift](https://cocoacasts.com/dependency-injection-in-swift)
* [SwinjectStoryboard](https://github.com/Swinject/SwinjectStoryboard)
* [Swift 5.1 Takes Dependency Injection to the Next Level](https://medium.com/better-programming/taking-swift-dependency-injection-to-the-next-level-b71114c6a9c6)
* [Builder Demo Application](https://github.com/hmlongco/Builder)

2 changes: 1 addition & 1 deletion Resolver.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Resolver"
s.version = "1.4.1"
s.version = "1.4.4"
s.summary = "An ultralight Dependency Injection / Service Locator framework for Swift on iOS."
s.homepage = "https://github.com/hmlongco/Resolver"
s.license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions Resolver.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@
isa = PBXProject;
attributes = {
LastSwiftMigration = 9999;
LastUpgradeCheck = 1220;
LastUpgradeCheck = 1250;
};
buildConfigurationList = OBJ_2 /* Build configuration list for PBXProject "Resolver" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = OBJ_5;
productRefGroup = OBJ_24 /* Products */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1220"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit 653db1b

Please sign in to comment.