Skip to content
Snippets Groups Projects
Commit b92f2a69 authored by Taras's avatar Taras
Browse files

Debounce timeline updates

parent cf265a27
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ import kotlinx.coroutines.Dispatchers ...@@ -5,6 +5,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.mapLatest
...@@ -57,6 +58,7 @@ abstract class BaseTimelineDataSource( ...@@ -57,6 +58,7 @@ abstract class BaseTimelineDataSource(
startTimeline(listener) startTimeline(listener)
awaitClose() awaitClose()
}.flowOn(Dispatchers.IO) }.flowOn(Dispatchers.IO)
.debounce(150)
.mapLatest { .mapLatest {
val items = timelineBuilder.build(it, isThread) val items = timelineBuilder.build(it, isThread)
if (it.isNotEmpty() && items.size <= LOAD_MORE_THRESHOLD) loadMore() if (it.isNotEmpty() && items.size <= LOAD_MORE_THRESHOLD) loadMore()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment