Skip to content

Commit

Permalink
Add a small debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Nov 2, 2023
1 parent 8ae728a commit a73b34b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlin.time.Duration.Companion.milliseconds

/**
* Search view model to search media for the chosen bu
Expand All @@ -46,7 +48,7 @@ class SearchViewModel(private val ilRepository: ILRepository) : ViewModel() {
*/
val query: StateFlow<String> = _query

private val config = combine(bu, query) { bu, query -> Config(bu, query) }
private val config = combine(bu, query) { bu, query -> Config(bu, query) }.debounce(600.milliseconds)

/**
* Result of the search trigger by [bu] and [query]
Expand Down

0 comments on commit a73b34b

Please sign in to comment.