shaunpersad/throttled-queue

Need a flag to invoke immediately

joelnet opened this issue · 4 comments

I would like to throttle requests, but fire immediately the first request.

Example:

import throttledQueue from 'throttled-queue'

const throttle = throttledQueue(1, 10000)

console.log('start')

throttle(() => console.log('1'))
throttle(() => console.log('2'))
throttle(() => console.log('3'))
throttle(() => console.log('4'))
throttle(() => console.log('5'))

It takes 10 seconds before 1 is output, I would like start and 1 to output immediately and wait 10 seconds for 2 to output.

Cheers!

@joelnet @shaunpersad did you end up finding a solution to this? Im facing the same issue right now

I ended up changing requirements so I no longer needed the solution. Eventually I moved to rxjs.

This is still the behavior - I might do a pull request later if I get around to it.

I believe #7 addresses this by making the first call immediate but maintaining all future calls