The Drip framework is a lightweight dependency injection framework (in terms of the API exposed to the client), has a relatively simple integration process (minimize XCode project modifications), easy to debug, and also robust, dealing gracefully with errors when they do arise. Lastly, well covered with unit testing. All this made with Swift for Swift.
Drip primarily uses SwiftPM as its build tool, so we recommend using that as well. If you want to depend on Drip in your own project, it's as simple as adding a dependencies
clause to your Package.swift
:
dependencies: [
.package(url: "https://github.com/Angel-Cortez/Drip", from: "0.0.1")
]
- Depedency Resoultion - functions, classes, and structs
- Code generation
- Circular Dependency detection
// ^->RootComponent
class RootComponent: OmegaComponent {
/// The singleton instance.
public static let instance = RootComponent()
}
// ^->RootComponent->AComponent
class AComponent: Component {
/// The singleton instance.
public static let instance = AComponent(parent: RootComponent.instance)
}
__Registry.instance.registerDependencyProviderFactory(for: AComponent.instance.get(NetworkManager.self)) {
return NewNetworkManager() as AnyObject
}
class ViewController {
@Inject(AComponent.instance.get(NetworkManager.self))
var manager: NetworkManager?
}