Skip to content

Instantly share code, notes, and snippets.

@aleksandra-majchrzak
Created May 10, 2021 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleksandra-majchrzak/58094a2861ac77859f9bb90190e4acaa to your computer and use it in GitHub Desktop.
Save aleksandra-majchrzak/58094a2861ac77859f9bb90190e4acaa to your computer and use it in GitHub Desktop.
Example 2 for Kotlin Shared Flow article
fun uploadData(): Flow<UpdateStep> = flow {
emit(UpdateStep.Step1)
doUpdateStep1()
emit(UpdateStep.Step2)
doUpdateStep2()
emit(UpdateStep.Step3)
doUpdateStep3()
emit(UpdateStep.Success)
}.catch {
emit(UpdateStep.Error(it))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment