Skip to content

Instantly share code, notes, and snippets.

@raph-amiard
Created June 14, 2013 09:31
Show Gist options
  • Save raph-amiard/5780639 to your computer and use it in GitHub Desktop.
Save raph-amiard/5780639 to your computer and use it in GitHub Desktop.
function run_async_sleep(action_fn) {
wait_times = action_fn()
function internal() {
try {
wait_time = wait_times.next()
} catch (_) {
return;
}
if (wait_time) {
setTimeout(internal, wait_time);
}
}
internal()
}
run_async_sleep(function() {
console.log("Hello 1");
yield 500;
console.log("Hello 2");
yield 500;
console.log("Hello 3");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment