[Request] Kill queue but execute drain function.
AoDev opened this issue · comments
AoDev commented
Hello, I wanted to ask to be able to execute the drain function on kill
.
The reason is that the user might cancel the process because it's too long but still wants things to happen with the already processed tasks.
I could implement such thing on my side.
But, checking the kill function code,
I think it would be easier to simply be able to call:
queue.killAndDrain()
// whatever the final API would be
function killAndDrain () {
queueHead = null
queueTail = null
self.drain()
self.drain = noop
}
What do you think?
Matteo Collina commented
It seems a nice feature. Would you like to send a PR?
AoDev commented
PR Submitted. I am not familiar with tape, so I have just copied the kill test but check for the drain function to be called. Let me know if we should change anything.