- 授权协议: MIT
- 开发语言: Swift
- 操作系统: 跨平台
- 软件首页: https://github.com/Seanwong933/SGAPIRequest
- 软件文档: http://siegrain.wang/post/api-request-step-by-step
- 官方下载: https://github.com/Seanwong933/SGAPIRequest
软件介绍
SGAPIRequest 是用 Moya + PromiseKit 创建具有序列化及缓存功能的网络请求层。
第一次使用
Swift来做项目,第一步当然就是折腾架构,由于项目时间比较宽裕,使用了较多的时间来进行学习参照,最后使用了这样的架构来作为这个产品的网络层,满足了项目基本的需求,肯定有不少的缺陷,权当各位参考。
先来看看最终我们要达成的目标,下面是一段异步请求接口的代码,这段代码具有网络请求、序列化及基本的缓存功能。
firstly { () -> Promise<[ArticleCategoryModel?]?> in
return CallApi(DFAPI.navigations, isCached: true)
}.then { [weak self] (data) -> Void in
self!.navigations = data!
}这一段请求,由以下4个库实现:
