Skip to content
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

How can I fetch the data from cache when fetching data from remote failed? #55

Open
arohim opened this issue Mar 14, 2019 · 1 comment

Comments

@arohim
Copy link

arohim commented Mar 14, 2019

Hi, I'm new on Clean architecture and we are planning to convert our project(MVP) to Clean architecture and I'm making POC project from our code base and see how it goes for my team.

as the sample code, the data fetch from the cache only the cache not expired or cached in our case is fetch the data from cached when fetching the data from network failed whatever case.

Any ideas?

@piotrek1543
Copy link

piotrek1543 commented Apr 22, 2019

There are some empty methods which you can use for your purpose:

override fun showErrorState() {
   }

   override fun hideErrorState() {
   }

   override fun showEmptyState() {
   }

   override fun hideEmptyState() {
   }

Show an error message with Retry button when showErrorState is called, the method retry/refresh() would be available in presenter/viewModel - it will retry the whole network request from the beginning.

You can also use SwipeToRefreshLayout instead of ProgressBar, so for empty/error you would show only message and user will swipe to get new data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants