ubu
05/25/2020, 5:59 PMdebounce()
) value inside a `Flow`:
val changesChannel: Channel<String>
val changes: Flow<String> = changesChannel.consumeAsFlow()
which is collected in the following manner:
changes.debounce().map { saveChange(it) }.collect()
Due to some race condition, I need to prevent to save currently pending value (i.e. value that is scheduled to be persisted after debounce timeout). I could go by overwriting current value. For that, I would create:
sealed class Change {
/**
* Active change value
*/
data class Active(val text: String) : Change()
/**
* Idle change value (value was previously cleared)
*/
object Idle : Change()
}
Is there a better way to go? 🦄