Skip to content

Using withContext { } instead of Flow for long running task #2

@YogeshUmeshVaity

Description

@YogeshUmeshVaity

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions