Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit fe9cc6b

Browse files
committed
Merge branch 'release/0.6.1' into versions
2 parents 3cbfb67 + b1a6832 commit fe9cc6b

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: swift test -v
2828

2929
test-macos:
30-
runs-on: macOS-latest
30+
runs-on: macos-11
3131

3232
steps:
3333
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
1717
### Security
1818
- None.
1919

20+
## [0.6.1] - 2021-10-14
21+
### Changed
22+
- Made the `baseUrl` parameter of `ApiProvider` editable.
23+
2024
## [0.6.0] - 2021-09-30
2125
### Added
2226
- New async `response` method based on the new concurrency features available in Swift 5.5.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PackageDescription
33

44
let package = Package(
55
name: "Microya",
6-
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13)],
6+
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)],
77
products: [
88
.library(name: "Microya", targets: ["Microya"])
99
],

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
alt="codebeat badge">
1414
</a>
1515
<a href="https://github.com/Flinesoft/HandySwift/releases">
16-
<img src="https://img.shields.io/badge/Version-0.6.0-blue.svg"
17-
alt="Version: 0.6.0">
18-
<img src="https://img.shields.io/badge/Swift-5.3-FFAC45.svg"
19-
alt="Swift: 5.3">
16+
<img src="https://img.shields.io/badge/Version-0.6.1-blue.svg"
17+
alt="Version: 0.6.1">
18+
<img src="https://img.shields.io/badge/Swift-5.4-FFAC45.svg"
19+
alt="Swift: 5.4">
2020
<img src="https://img.shields.io/badge/Platforms-Apple%20%7C%20Linux-FF69B4.svg"
2121
alt="Platforms: Apple | Linux">
2222
<a href="https://github.com/Flinesoft/Microya/blob/main/LICENSE.md">
@@ -277,6 +277,22 @@ provider.publisher(on: endpoint, decodeBodyTo: TranslationsResponse.self)
277277
.store(in: &cancellables)
278278
```
279279

280+
### Concurrency Support
281+
282+
If you are using Swift 5.5 in your project and your minimum target is iOS/tvOS 15+, macOS 12+ or watchOS 8+, you might want to use the `async` method `response` instead. For example, the usage might look something like this:
283+
284+
```Swift
285+
let result = await provider.response(on: endpoint, decodeBodyTo: TranslationsResponse.self)
286+
287+
switch result {
288+
case let .success(translationsByLanguage):
289+
// use the already decoded `[String: String]` result
290+
291+
case let .failure(apiError):
292+
// error handling
293+
}
294+
```
295+
280296
### Plugins
281297

282298
The initializer of `ApiProvider` accepts an array of `Plugin` objects. You can implement your own plugins or use one of the existing ones in the [Plugins](https://github.com/Flinesoft/Microya/tree/main/Sources/Microya/Plugins) directory. Here's are the callbacks a custom `Plugin` subclass can override:
@@ -331,8 +347,6 @@ public var decoder: JSONDecoder { JSONDecoder() }
331347

332348
public var encoder: JSONEncoder { JSONEncoder() }
333349

334-
public var plugins: [Plugin<Self>] { [] }
335-
336350
public var headers: [String: String] {
337351
[
338352
"Content-Type": "application/json",
@@ -351,7 +365,6 @@ So technically, the `Endpoint` type only requires you to specify the following 4
351365
```swift
352366
protocol Endpoint {
353367
associatedtype ClientErrorType: Decodable
354-
var baseUrl: URL { get }
355368
var subpath: String { get }
356369
var method: HttpMethod { get }
357370
}

Sources/Microya/Core/ApiProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ open class ApiProvider<EndpointType: Endpoint> {
1717
public let plugins: [Plugin<EndpointType>]
1818

1919
/// The common base URL of the API endpoints.
20-
public let baseUrl: URL
20+
public var baseUrl: URL
2121

2222
/// The mocking behavior of the provider. Set this to receive mocked data in your tests. Use `nil` to make actual requests to your server (the default).
2323
public let mockingBehavior: MockingBehavior<EndpointType>?

0 commit comments

Comments
 (0)