[FLOW] collect the latest emitted value after some time from the latest emission
See original GitHub issueI’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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
[FLOW] how to collect the latest emitted value after some time ...
I'm not sure how to explain my usecase. I have a textfield that emits on each text change but I need to collect...
Read more >Flow wait some time, then gather all emitted elements into a ...
The short answer is that there is no built-in function for this at the moment AFAIK. I think what you're looking for is...
Read more >Asynchronous Flow - Kotlin
The collection works directly in the coroutine that calls a terminal operator. No new coroutines are launched by default. Each emitted value ......
Read more >Kotlin flows on Android - Android Developers
The flow builder function creates a new flow where you can manually emit new values into the stream of data using the emit...
Read more >Introduction to the Kotlin Flow Class - Baeldung
Each time one of the flows emits a new value, it will recalculate the ... 1 Before wating: 2 About to emit: 2...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In fact, I miss something like a sample but with the last value emitted
I need the same thing did you found something useful ?