Comments (3)
删了APP设置下缓存策略
from rxnetwork.
OnCache+Demo.swift
requestObject 方法指定了 CleanJSONDecoder 缓存正常
import RxSwift
import RxNetwork
import CleanJSON
extension OnCache {
public func requestObject() -> Single<C> {
return target.request()
.storeCachedResponse(for: target)
.map(Network.Response<C>.self, using: CleanJSONDecoder())
.map {
if $0.success {
return $0.data
}
throw Network.Error.status(code: $0.code, message: $0.message)
}
}
}
onCache获取缓存需指定解析对应路径
/*
{
"code": 2000,
"message": "Ok",
"result": []
}
*/
BannerAPI.test(count: 10)
.onCache([BannerModel].self, atKeyPath: "result", using: CleanJSONDecoder(), { (models) in
debugPrint("onCache:", models.first?.name ?? "")
})
.requestObject()
.subscribe(onSuccess: { (models) in
debugPrint("onSuccess:", models.first?.name ?? "")
}, onError: { (error) in
debugPrint("error:", error)
})
.disposed(by: disposeBag)
from rxnetwork.
这个是正常的,JSON 解析失败导致的,Demo 里面我没有处理这个,多谢反馈。
from rxnetwork.
Related Issues (6)
- OnCache 方法不支持指定路径的解析和缓存 HOT 1
- 一些关于 podspec 文件的小建议。 HOT 2
- Endpoint的自定义 HOT 2
- provide在RxNetwork如何配置?
- 缓存问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxnetwork.