|
| 1 | +# 🍫 swift-nibbles |
| 2 | +[](https://github.com/connor-ricks/swift-exploration-nibbles/actions/workflows/pull_request_checks.yaml) |
| 3 | +[](https://codecov.io/gh/connor-ricks/swift-nibbles) |
| 4 | + |
| 5 | +Nibbles of useful swift code that I regularaly use across various proejcts. |
| 6 | + |
| 7 | +## Getting Started |
| 8 | + |
| 9 | +To add `swift-nibbles` to your project, first add it as a dependency. |
| 10 | + |
| 11 | +```swift |
| 12 | +.package(url: "https://github.com/connor-ricks/swift-nibbles/", branch: "main") |
| 13 | +``` |
| 14 | + |
| 15 | +Nibbles are all broken down into their own targets, so you can choose which nibbles are relevant to your project. |
| 16 | + |
| 17 | +```swift |
| 18 | +.product(name: "HTTPNetworking", package: "swift-nibbles") |
| 19 | +// or |
| 20 | +.product(name: "Cache", package: "swift-nibbles") |
| 21 | +``` |
| 22 | + |
| 23 | +## Nibbles |
| 24 | + |
| 25 | +### 🗄️ Cache |
| 26 | +A simple cache that can be used to store objects. |
| 27 | + |
| 28 | +Use a cache to store objects of a given type in memory using an associated key. |
| 29 | +You can then fetch attempt to retrieve from the cache at a later time using the key. |
| 30 | + |
| 31 | +### ⛓️ Extensions |
| 32 | +A collection of useful extensions that I freqeuntly implement across multiple projects. |
| 33 | + |
| 34 | +### 🕸️ HTTPNetworking |
| 35 | +A client that creates and manages requests over the network. |
| 36 | + |
| 37 | +The client provides support for sharing common functionality across all requests, but each request can also layer on additional functionality if needed. |
| 38 | + |
| 39 | +Using the concept of plugins, you can customize your client's functionalities to your needs. |
| 40 | + |
| 41 | +- **Adaptors:** Mutate a `URLRequest` before it is dispatched over the network. Useful for adding headers or query parameters to outbound requests. |
| 42 | +- **Validators** Validate the `HTTPURLResponse` and `Data` of a `URLRequest` before decoding. Useful for checking status codes and other common validation stratagies. |
| 43 | +- **Retriers** Retry failed requests on your terms. |
| 44 | + |
| 45 | +Generally an ``HTTPClient`` is used to manage the interaction with a single API service. Most APIs |
| 46 | +have their own nuance and complexities, and encapsulating all of that in one place can help structure your code in a |
| 47 | +more scalable and testable way. |
| 48 | + |
| 49 | +### 🏷️ Identified |
| 50 | + |
| 51 | +A protocol for marking objects as identified and allowing interaction with their identifiers in a type-safe way. |
| 52 | + |
| 53 | +## License |
| 54 | + |
| 55 | +[MIT License](https://github.com/connor-ricks/swift-nibbles/blob/main/LICENSE) |
0 commit comments