Why can't the emit() operation of Flow after emitAll() be launched in Kotlin ? and onCompletion{} can't be launched too - TagMerge
1Why can't the emit() operation of Flow after emitAll() be launched in Kotlin ? and onCompletion{} can't be launched tooWhy can't the emit() operation of Flow after emitAll() be launched in Kotlin ? and onCompletion{} can't be launched too

Why can't the emit() operation of Flow after emitAll() be launched in Kotlin ? and onCompletion{} can't be launched too

Asked 11 months ago
3
1 answers

A Flow from a Room DAO never completes. It is infinite because it monitors the database for changes forever. So when you call collect on it (which is what emitAll is doing internally), the function never returns and no code written under it will ever be reached. The flow will only be stopped when the coroutine that is collecting it is cancelled.

Source: link

Recent Questions on kotlin

    Programming Languages