Skip to content

Instantly share code, notes, and snippets.

@PaulWoitaschek
Created July 17, 2019 14:02
Show Gist options
  • Save PaulWoitaschek/6220f24ea69172350ac03dbaff1b91b0 to your computer and use it in GitHub Desktop.
Save PaulWoitaschek/6220f24ea69172350ac03dbaff1b91b0 to your computer and use it in GitHub Desktop.
fun state(): Flow<DiaryFoodTimeViewState> {
val foodTimeName = foodTimeNamesProvider[args.foodTime]
val baseState = DiaryFoodTimeViewState(
title = foodTimeName,
loading = true,
error = null,
canTakePicture = true,
content = null
)
val contentFlow = foodTimeImagesRepo.get(args.date)
.map {
val image = it[args.foodTime]
DiaryFoodTimeContent(image)
}
.map { content ->
baseState.copy(loading = false, content = content, error = null)
}
return flow {
emit(baseState)
emitAll(contentFlow)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment