Comments (6)
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.
About your use case. Why don't you want to update adapter on resume? Why do you need to recreate it?
from nucleus.
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.
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.
the only place where restartableLatestCache
have meaning is onCreate
from nucleus.
Oh, I see - I misunderstood restartableLatestCache
(and friends). Thanks.
from nucleus.
Related Issues (20)
- Best practice for normal case. (get support.) HOT 3
- Wondering about multiple Presenter endpoint calls (Question) HOT 2
- How to get onComplete using restartable methods? HOT 1
- How could i force restartableFirst.onError with mockito? HOT 1
- RxJava latest version not used. HOT 1
- Console error saving file HOT 1
- Activity method called every time HOT 2
- (Question) Don't keep activieties option HOT 1
- Confusion about restartables and the Activity lifecycle HOT 3
- Does Nucleus support native Fragments? HOT 2
- Throwing VerifyError in < API 21 HOT 1
- Question regarding getView() and reference the View in the presenter. HOT 11
- Nucleus with Dagger 2 HOT 3
- NucleusActionBarActivity with support library 26 HOT 13
- Help with injecting Presenter when using AndroidInjector HOT 3
- Calling setPresenter in OnCreate HOT 2
- clear the delivery cache
- Crashes when starting a new activity using kotlin
- upgrade a new version for androidx, please
- getView() deprecated
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 nucleus.