Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swiftylab/swift-contexts
A no-boilerplate dependency management library for Swift.
https://github.com/swiftylab/swift-contexts
architecture dependency-injection dependency-inversion dependency-management solid solid-principles swift swiftui
Last synced: 4 days ago
JSON representation
A no-boilerplate dependency management library for Swift.
- Host: GitHub
- URL: https://github.com/swiftylab/swift-contexts
- Owner: SwiftyLab
- License: mit
- Created: 2023-10-05T18:13:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-23T11:28:31.000Z (about 1 year ago)
- Last Synced: 2024-07-30T18:03:54.307Z (6 months ago)
- Topics: architecture, dependency-injection, dependency-inversion, dependency-management, solid, solid-principles, swift, swiftui
- Language: Swift
- Homepage: https://swiftylab.github.io/swift-contexts/documentation/contexts/
- Size: 322 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# swift-contexts
[![API Docs](http://img.shields.io/badge/Read_the-docs-2196f3.svg)](https://swiftylab.github.io/swift-contexts/documentation/Contexts/)
[![Swift Package Manager Compatible](https://img.shields.io/github/v/tag/SwiftyLab/swift-contexts?label=SPM&color=orange)](https://badge.fury.io/gh/SwiftyLab%2Fswift-contexts)
[![Swift](https://img.shields.io/badge/Swift-5.2+-orange)](https://img.shields.io/badge/Swift-5-DE5D43)
[![Platforms](https://img.shields.io/badge/Platforms-all-sucess)](https://img.shields.io/badge/Platforms-all-sucess)
[![CI/CD](https://github.com/SwiftyLab/swift-contexts/actions/workflows/main.yml/badge.svg)](https://github.com/SwiftyLab/swift-contexts/actions/workflows/main.yml)
[![CodeFactor](https://www.codefactor.io/repository/github/swiftylab/swift-contexts/badge)](https://www.codefactor.io/repository/github/swiftylab/swift-contexts)
[![codecov](https://codecov.io/gh/SwiftyLab/swift-contexts/branch/main/graph/badge.svg?token=XcGO9JCN9Q)](https://codecov.io/gh/SwiftyLab/swift-contexts)A no-boilerplate dependency management library for Swift.
## Overview
When following [Single responsibility](https://en.wikipedia.org/wiki/Single-responsibility_principle) in [SOLID](https://en.wikipedia.org/wiki/SOLID) principle, code is divided into multiple types/functions each representing a responsibility/goal, i.e. storage access, database and networking, scheduling etc.
These types/functions can depend on each other and it is important these dependences need to be controlled to deterministically test each responsibility, free from side effects from external components, i.e. file systems, network connectivity and speed, server uptime etc.
This library addresses this concern by allowing controlling dependencies with following features:
- Propagating dependencies throughout application in a way that is more ergonomic than explicitly passing them around everywhere, but safer than having a global dependency.
- Override dependencies in different parts of application for testing or customizing experiences in various parts.## Requirements
| Platform | Minimum Swift Version | Installation | Status |
| --- | --- | --- | --- |
| iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ | 5.2 | Swift Package Manager | Fully Tested |
| Linux | 5.2 | Swift Package Manager | Fully Tested |
| Windows | 5.2 | Swift Package Manager | Fully Tested |## Installation
Swift Package Manager
The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.
Once you have your Swift package set up, adding `swift-contexts` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.
```swift
.package(url: "https://github.com/SwiftyLab/swift-contexts.git", from: "1.0.0"),
```Then you can add the `Contexts` module product as dependency to the `target`s of your choosing, by adding it to the `dependencies` value of your `target`s.
```swift
.product(name: "Contexts", package: "swift-contexts"),
```## Usage
See the full [documentation](https://swiftylab.github.io/swift-contexts/documentation/Contexts/) for API details and use cases.
## Contributing
If you wish to contribute a change, suggest any improvements,
please review our [contribution guide](CONTRIBUTING.md),
check for open [issues](https://github.com/SwiftyLab/swift-contexts/issues), if it is already being worked upon
or open a [pull request](https://github.com/SwiftyLab/swift-contexts/pulls).## License
`swift-contexts` is released under the MIT license. [See LICENSE](LICENSE) for details.