Vaibhav Jaiswal
03/09/2024, 7:34 AMmutableStateOf
for a text field and a snapshotFlow
version of it in my viewmodel,
How can i create a flow
for typing indicator type of feature
Like when there are emissions in the snapshot flow, it should be true and when there are no emission for like 3seconds, it will be false
Again snapshot flow got new emissions, and its again true
Any idea?Albert Chang
03/09/2024, 8:02 AMsnapshotFlow { textFieldValue }
.transformLatest {
emit(true)
delay(3000)
emit(false)
}
.distinctUntilChanged()
Vaibhav Jaiswal
03/09/2024, 8:03 AMVaibhav Jaiswal
03/09/2024, 8:04 AMAlbert Chang
03/09/2024, 8:06 AMWhen the original flow emits a new value, the previousblock is cancelled, thus the nametransform
.transformLatest
Vaibhav Jaiswal
03/09/2024, 8:06 AMHalil Ozercan
03/09/2024, 3:30 PMTextFieldValue
, the flow will also emit when the cursor or selection position changes. If you are only interested in typing, only observe the text contents of the value.Jrichards1408
03/10/2024, 1:10 AMJrichards1408
03/10/2024, 1:21 AM