https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

Michael Clancy

11/09/2021, 3:18 PM
Hi there, I am looking to apply a computationally expensive transformation to items in a flow, emitting intermediate signals indicating the progress of this transformation. (Emitting multiple times from .transform). If certain error conditions are met during this transformation, I want to skip the rest of the function being applied, and move onto the next item in the flow.
someFlow.transform {
if (someCondition) {
emit(Resource.Loading(someIntermediateResult))
} else {
emit(Resource.Error("Couldn't compute")
//Want to place something here to skip code below and move to next item in flow
}
emit(Resource.Success(finalResult)
Any ideas? Feel like I am missing something simple Thanks, Michael
e

ephemient

11/09/2021, 7:51 PM
return@transform
will exit the lambda expression early
❤️ 1
m

Michael Clancy

11/10/2021, 9:30 AM
Thank you!
3 Views