can someone please explain the difference between ...
# coroutines
l
can someone please explain the difference between
Copy code
Flow<T>.debounce and Flow<T>.sample
I read the documentation and don't really understand when i would use one or the other. I have the following code:
Copy code
informService.informCount.debounce(250.milliseconds)
informCount is a StateFlow that gets updated super fast it doesn't seem to work (not emitting anything). Should I use sample instead of debounce or no?
o
sample continuously emits every
period
of time, debounce only emits after no events occur for
period
of time
for your use case, you probably want to
sample
so that you get something even if it keeps updating
j
Just to clarify @octylFractal's explanation slightly,
debounce
emits the latest event after no events occur for a period of time.
l
thanks