Kotlin-Flow-Android-Examples icon indicating copy to clipboard operation
Kotlin-Flow-Android-Examples copied to clipboard

Using withContext { } instead of Flow for long running task

Open YogeshUmeshVaity opened this issue 5 years ago • 0 comments

Hi, first, thanks for creating these examples. I have a few questions:

So, as we know, Flow is used for returning multiple asynchronously computed values. But here we are only doing a single task and returning a single value. Wouldn't it be more appropriate to use suspend function along with withContext { } instead of Flow for a single long running task?

I was wondering why have you used Flow? Does it offer any adavantage over withContext { } in this case?

In case, this example is only for demonstration purposes? Don't we need a more suitable example?

YogeshUmeshVaity avatar May 25 '20 15:05 YogeshUmeshVaity