Giter Site home page Giter Site logo

demo中仅加载缓存(当缓存无数据时),还有先加载缓存后加在网络(第一次无缓存,无网络)这两种情况下,页面始终显示加载中,debug时onNext和onError均没有进入断点。 about rxcache HOT 5 CLOSED

z-chu avatar z-chu commented on May 10, 2024
demo中仅加载缓存(当缓存无数据时),还有先加载缓存后加在网络(第一次无缓存,无网络)这两种情况下,页面始终显示加载中,debug时onNext和onError均没有进入断点。

from rxcache.

Comments (5)

z-chu avatar z-chu commented on May 10, 2024

是这样没错,你用2.0版的话。因为RxJava2.0不能发出null值,你的以上2种情况使用的是 Observable.empty()
如需定制,你可以继承BaseStrategy 或者去实现IStrategy
另外RxCache还有saveload方法,返回的是Observable,你可以不使用compose(rxCache.<~>transformer...))方式,自由组合成你想要的策略

from rxcache.

caprice avatar caprice commented on May 10, 2024

明白,看来是需要定制了。需求缓存策略是:先加载缓存数据到页面,再网络数据。用户第一次进入时,没网络,没缓存,再看网络请求是否成功。onError最终就要onError。当缓存有数据时,即使网络出现onError, 页面数据也还是应该显示缓存数据,顶多用toast提醒用户"网络错误",这个看起来有些麻烦啊

from rxcache.

z-chu avatar z-chu commented on May 10, 2024

这确实是个问题,如果缓存没取到,网络onError了,最终就应该是要onError,而不是直Observable.empty(),不过你的这个需求在CacheAndRemotoStrategy的基础上修改很容易实现,我打算下个版本把这个问题解决。

from rxcache.

caprice avatar caprice commented on May 10, 2024

image
目前这样自己写一个就可以了,后面再参照你更好的做法。再一次感谢你的这个lib.

from rxcache.

z-chu avatar z-chu commented on May 10, 2024

已更新,已修复,使用v2.0.5版即可

from rxcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.