Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelesantos/refds-injection
RefdsInjection is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications. With RefdsInjection, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.
https://github.com/rafaelesantos/refds-injection
dependency-injection refds refds-injection swift swift-package-manager
Last synced: 5 days ago
JSON representation
RefdsInjection is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications. With RefdsInjection, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.
- Host: GitHub
- URL: https://github.com/rafaelesantos/refds-injection
- Owner: rafaelesantos
- License: mit
- Created: 2024-03-16T05:45:57.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-09-12T14:15:18.000Z (2 months ago)
- Last Synced: 2024-09-13T02:26:41.812Z (2 months ago)
- Topics: dependency-injection, refds, refds-injection, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 💉 Refds Injection
[![Swift](https://github.com/rafaelesantos/refds-injection/actions/workflows/swift.yml/badge.svg?branch=main)](https://github.com/rafaelesantos/refds-injection/actions/workflows/swift.yml)
`RefdsInjection` is a Swift library that provides a simple yet powerful solution for dependency injection in your iOS, macOS, and other Swift applications.
With `RefdsInjection`, you can manage your components' dependencies cleanly and efficiently, easing the development, testing, and maintenance of your codebase.## Installation
Add this project to your `Package.swift` file.
```swift
import PackageDescriptionlet package = Package(
dependencies: [
.package(url: "https://github.com/rafaelesantos/refds-injection.git", branch: "main")
],
targets: [
.target(
name: "YourProject",
dependencies: [
.product(
name: "RefdsInjection",
package: "refds-injection"),
]),
]
)
```## Usage
```swift
import RefdsInjectionprotocol MockViewModelProtocol {
var id: UUID { get }
}class MockViewModel: MockViewModelProtocol {
var id: UUID
init(id: UUID) { self.id = id }
}let expectedID = UUID()
RefdsContainer.register(type: MockViewModelProtocol.self) { MockViewModel(id: expectedID) }
let viewModel = RefdsContainer.resolve(type: MockViewModelProtocol.self)
let receivedID = viewModel.id
```