Created
June 14, 2013 09:31
-
-
Save raph-amiard/5780639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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