-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deliverLatestCache() example #51
Comments
In your subscription you should call a method of your view that updates the data. When you rotate the screen, the last result will be given again to the view, without repeating the query or network call or whatever. You don't have to do anything else. You can use restartable*, a pseudocode example here: #42 (comment) And a real example (with lambdas): MyPresenter:
Or you can use the deilver* methods, for example: MyPresenter:
I would use the restartable approach. It allows you to start the observable whenever you want, with the start(x) method, so that you can provide some parameters to the query first. Just make sure you are not restarting the observable when a configuration change occurs in order to take advantage of these deliver* methods. If you use the second approach, don't forget to wrap the observable with the add() method, so that it unsubscribes when the presenter is destroyed. |
Hi konmik,
I'm using this library into my app and I find it great and easy to use. I have a little problem with deliverLatestCache() method. You said that:
deliverLatestCache() is the same as deliverLatest() but in addition it will keep the latest result in memory and will re-deliver it when another instance of a view becomes available (i.e. on configuration change). If you don't want to organize save/restore of a request result in your view (in case if a result is big or it can not be easily saved into Bundle) this method will allow you to make user experience better.
and I'm trying to get this latest result but I don't understand what I have to do with it. Can you make an example of use for this method?
Thanks a lot.
The text was updated successfully, but these errors were encountered: