Giter VIP home page Giter VIP logo

Comments (6)

konmik avatar konmik commented on August 21, 2024

Hi,

The idea is that data normally gets updated on some internal event (pull to refresh, synchronization, etc). So the data-to-view pipeline should be reusable and there should be no difference between sending data once, twice, on each resume, on each recreation, etc.

I may probably change this behaviour in next versions, but I see no reason for doing this. Saving a couple of ms during onResume will come at the cost of slightly increased complexity. When there is no clear advantage I prefer simpler solutions.

from nucleus.

konmik avatar konmik commented on August 21, 2024

About your use case. Why don't you want to update adapter on resume? Why do you need to recreate it?

from nucleus.

sreejithraman avatar sreejithraman commented on August 21, 2024

In that scenario, it was a non-paging list so it didn't matter if i recreated it. But I guess it is better practice to save a reference to the adapter rather than recreate it every time.

To follow up on the paging, I had a question regarding deliverReplay(). In you paging example, you use restartableReplay to spit back the fetched Items to the view. From you documentation it says that this "keeps all onNext values and emits them each time a new view gets attached." I just wanted to clarify on this. Does it emit all items only when a view is attached and otherwise just emits the most recently fetched?

EDIT: for those seeing this at a later date, the answer is yes, it emit all items only when a view is attached and otherwise just emits the most recently fetched.

from nucleus.

BoneDaddy2016 avatar BoneDaddy2016 commented on August 21, 2024

The idea is that data normally gets updated on some internal event (pull to refresh, synchronization, etc).

@konmik How would you go about implementing this (pull-to-refresh, etc.) for something like a Retrofit service Observable? I have approximately the following in my RxPresenter:

public void fetchData(String someInput) {
    final Observable<List<Thing>> getThings = service.getStuff(someInput);

    restartableLatestCache(RESTARTABLE_THINGS,
            () -> getThings
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread()),
            ThingsActivity::onNewData,
            ThingsActivity::onError);

    start(RESTARTABLE_THINGS);
}

This is called manually by the user from the view (as it requires user input). As it stands, it works great and caches the data so it doesn't repeat network queries on configuration change, etc. as expected. But what if I wanted to add swipe-to-refresh? How would I "invalidate the cache" here?

Thanks!

from nucleus.

konmik avatar konmik commented on August 21, 2024

the only place where restartableLatestCache have meaning is onCreate

from nucleus.

BoneDaddy2016 avatar BoneDaddy2016 commented on August 21, 2024

Oh, I see - I misunderstood restartableLatestCache (and friends). Thanks.

from nucleus.

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.