architecture-components-samples
architecture-components-samples copied to clipboard
NetworkBoundResource retry/refresh doesn't work
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) {}
I have the same issue =( Did you find a way to make this work?