debounce-promise icon indicating copy to clipboard operation
debounce-promise copied to clipboard

add maxWait option

Open pbadenski opened this issue 5 years ago • 1 comments

Implements #11

pbadenski avatar Oct 25 '18 11:10 pbadenski

Hey and thanks @pbadenski. I like the idea, but wondering if flush should be scheduled using a setTimeout instead? If I understand your implementation correctly, the debounced function will now have to be called in order to check for maxWait to have passed, but maxWait may have already passed at that time.

e.g. using wait=1000, maxWait=4000

time (ms) ->
0       1000     2000     3000     4000     5000
|--------|--------|--------|--------|--------|
x   x  x  x    x    x  x    x   x x    x
                                    ^--- should have flushed here
                                       ^--- but will flush here

bjoerge avatar May 05 '19 17:05 bjoerge