Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-01 13:10:07 +05:00
parent aea7f5f415
commit c83ce2ada3
53 changed files with 1062 additions and 238 deletions

View file

@ -0,0 +1,34 @@
package com.tangem.core.ui.components.fields
import com.tangem.utils.coroutines.JobHolder
import com.tangem.utils.coroutines.withDebounce
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject
/**
* Search tokens manager
*
[REDACTED_AUTHOR]
*/
class InputManager @Inject constructor() {
val query: Flow<String>
get() = _query
private val _query = MutableStateFlow(value = "")
private val jobHolder = JobHolder()
suspend fun update(value: String) {
coroutineScope {
if (value.isEmpty()) {
jobHolder.cancel()
_query.value = value
} else {
withDebounce(jobHolder) { _query.value = value }
}
}
}
}