stephanenicolas / robospice

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
Apache License 2.0
2.95k stars 545 forks source link

getFromCacheAndLoadFromNetworkIfExpired - success is only called once #436

Open haemi opened 8 years ago

haemi commented 8 years ago

Hi,

I'm using Robospice like the following:

    getSpiceManager().getFromCacheAndLoadFromNetworkIfExpired(request, lastRequestCacheKey, DurationInMillis.ONE_SECOND, new RequestListener<MyList>() {
        @Override
        public void onRequestFailure(final SpiceException spiceException) {
        }

        @Override
        public void onRequestSuccess(final MyList list) {
            ...
        }
    });

I would expect the success block to be called twice (dirty cache/network), but it's only called once (after the network returns). What could be the reasons for thisß

anotherdev commented 8 years ago

The success callback is called only once in 3 cases:

  1. No data in cache, request succeeded.
  2. Cache exist but not dirty (not expired).
  3. Cache exist but the subsequential network call failed.

Issue 117