CombineNetwork 1.0.11

CombineNetwork 1.0.11

Adamas Zhu维护。



  • Adamas Zhu

CombineNetwork

Platform Cocoapods PM

CombineNetwork为使用Combine.framework进行网络调用提供了简单的接口。

安装

CocoaPods

Podfile中包含以下行:

pod CombineNetwork

Swift包管理器

使用当前GitHub URL添加Package Dependency

引用

示例

测试 JSON 文件

https://swapi.co/api

JSON 模型

struct StarWars: Decodable {
    let films: String
}

从 JSON 文件中检索数据

let client = APIClient()
let url = URL(string: "https://swapi.dev/api/")!
let subscriber = Subscribers.Sink<StarWars?, APIError>(
    receiveCompletion: { print($0) },
    receiveValue: { print($0) })
client.requestObject(from: url, using: .get)
    .subscribe(subscriber)