`getLongestCompletedStreak` can take a while if th...
# coroutines
f
getLongestCompletedStreak
can take a while if the List is large. Will this setup do the list calculation on a background thread?
Copy code
private val taskStreaksMax =
        allTasksWithTaskStatisticsFlow.map { allTasksWithTaskStatistics ->
            allTasksWithTaskStatistics.map { taskWithTaskStatistics ->
                TaskStreak(
                    taskWithTaskStatistics.task.id,
                    taskWithTaskStatistics.taskStatistics.getLongestCompletedStreak()
                )
            }
        }.flowOn(defaultDispatcher)
Ok, I think I figured it out myself. I put a
Thread.sleep
into my sorting function and indeed, with the
flowOn
it doesn't freeze the screen, but without it it does.
o
What is
defaultDispatcher
?
f
Dispatchers.Default
o
Ok, I assume the, getLongestCompletedStreak() function is suspending, and is the reason why it can take long?
f
no, its no suspending
because it doesn't call any suspend functions
it's just searches through a list