Skip to content

Instantly share code, notes, and snippets.

@Shivamdhuria
Last active December 12, 2020 20:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
private fun getDogImages(): Flow<ResultWrapper> {
return flow {
emit(ResultWrapper.Loading(true))
delay(3000)
val randomNumber = (0..5).random()
emit(ResultWrapper.Loading(false))
if (randomNumber < 3) {
throw IOException()
}
emit(ResultWrapper.Success(getList()))
}
}
private fun getList(): List<String> {
val list = listOf<String>(
"https://images.dog.ceo/breeds/retriever-curly/n02099429_935.jpg",
....
"https://images.dog.ceo/breeds/pekinese/n02086079_952.jpg"
)
return list
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment