43
[FLOW] collect the latest emitted value after some time from the latest emission...
source link: https://github.com/Kotlin/kotlinx.coroutines/issues/1613
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Comments
I'm not sure how to explain my usecase. I have a textfield that emits on each text change but I need to collect the latest value only when there aren't other emissions for 300ms flow { emit(1) // this won't be collected because 2' is emitted after 40ms ' delay(40) emit(2) // this won't be collected because '3' is emitted after 40ms delay(40) emit(3) // this will be collected because it's the latest emitted value }.specialOperatorWithoutAName(timeInMillis = 300) // I only want `3` after 380 milliseconds I hope someone can help me |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK