question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FLOW] collect the latest emitted value after some time from the latest emission

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

4reactions
michgauzcommented, Oct 24, 2019

In fact, I miss something like a sample but with the last value emitted

0reactions
amir1376commented, Jul 31, 2022

I need the same thing did you found something useful ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found