Skip to content

Instantly share code, notes, and snippets.

@keiji
Last active July 19, 2019 06:18
Show Gist options
  • Save keiji/524976ee2075ad69f5c7de9c4dc55a19 to your computer and use it in GitHub Desktop.
Save keiji/524976ee2075ad69f5c7de9c4dc55a19 to your computer and use it in GitHub Desktop.
val myFlow = flow {
emit(fileListRepository.getFileList(path, limit, offsetValue, refresh))
}.retry(RETRY_LIMIT) { throwable ->
throwable is IOException
}.catch { throwable ->
errorMessage.postValue(throwable.message)
isLoading.postValue(null)
}.onEach() {
hasNext = it.hasNext
pathListSnapshot.addAll(it.fileList)
pathList.postValue(pathListSnapshot)
errorMessage.postValue(null)
isLoading.postValue(null)
}
isLoading.postValue(myFlow)
myFlow.launchIn(coroutineScope)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment