architecture-components-samples icon indicating copy to clipboard operation
architecture-components-samples copied to clipboard

NetworkBoundResource retry/refresh doesn't work

Open marynovskyi opened this issue 7 years ago • 1 comments

I have a problem with implementing a retry/refresh button, following GithubBrowserSample. The problem is that I can't get data when try to reload data (when there was no internet connection and user tries to reload data or just use pullToRefresh to update data).

init { result.value = Resource.loading(null) @Suppress("LeakingThis") val dbSource = loadFromDb() result.addSource(dbSource) { data -> result.removeSource(dbSource) if (shouldFetch(data)) { fetchFromNetwork(dbSource) } else { result.addSource(dbSource) { newData -> setValue(Resource.success(newData)) } } } }

Here, when I try to reload data, I don't get callback for result.addSource(dbSource) {}

marynovskyi avatar Aug 23 '18 06:08 marynovskyi

I have the same issue =( Did you find a way to make this work?

TobiasSuhrborg avatar Nov 07 '18 14:11 TobiasSuhrborg