I'm trying to use libq to create a timeout for a function that may take too long to complete. So the case is that if the function completes in time, say 5 seconds, it's ok, otherwise I want the promise to be rejected. So I created a shared promise, with one branch running the function, and another running a .delay(5s).then(...). But now I want to "cancel" the delay task if my function was completed within 5s. What would be the preferred way for this?
Hello,
I'm trying to use libq to create a timeout for a function that may take too long to complete. So the case is that if the function completes in time, say 5 seconds, it's ok, otherwise I want the promise to be rejected. So I created a shared promise, with one branch running the function, and another running a .delay(5s).then(...). But now I want to "cancel" the delay task if my function was completed within 5s. What would be the preferred way for this?
Best regards, Tom,