Swiftpack.co - Angel-Cortez/drip as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Angel-Cortez.
Angel-Cortez/drip 0.0.1
Drip is a simple dependency injection (DI) system for Swift. 🚧 WARNING!: experimental implementation 🚧
⭐️ 0
πŸ•“ 2 weeks ago
.package(url: "https://github.com/Angel-Cortez/drip.git", from: "0.0.1")

Drip

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.


Getting Started

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")
]

🚧 WARNING!: experimental implementation 🚧

  • β˜‘ Depedency Resoultion - functions, classes, and structs
  • ☐ Code generation
  • ☐ Circular Dependency detection

Usage

Defining basic Components

// ^->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)
}

Providing Dependencies

__Registry.instance.registerDependencyProviderFactory(for: AComponent.instance.get(NetworkManager.self)) {
    return NewNetworkManager() as AnyObject
}

Dependency Resolution in class or struct

class ViewController {
    @Inject(AComponent.instance.get(NetworkManager.self))
    var manager: NetworkManager?
}

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Alpha Release
2 weeks ago

β€’Β Basic dependency resolution for classes, structs, and functions

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics