I am using node.js. I have this function that uses promises to introduce a delay between the execution of certain actions.
function do_consecutive_action() { Promise.resolve() .then(() => do_X() ) .then(() => Delay(1000)) .then(() => do_Y()) .then(() => Delay(1000)) .then(() => do_X()) .then(() => Delay(1000)) .then(() => do_Y()) ; }
I want this set of actions to be repeated forever. How can this be done in node.js?
EDIT: I started dispensing answers that use a repeating queue to solve the problem.
user6064424
source share