Last active
August 29, 2015 13:56
-
-
Save jcollum-hcg/9216786 to your computer and use it in GitHub Desktop.
sample of a repeatable async task with confirmation of repeat
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
readline = require("readline") | |
log = console.log | |
rl = readline.createInterface( | |
input: process.stdin | |
output: process.stdout | |
) | |
asyncTask = (cb) -> | |
log "starting task" | |
setTimeout( (-> cb()), 5000) | |
ask = () -> | |
rl.question "Hit enter to start, q to quit ", (answer) -> | |
if answer == "q" | |
process.exit() | |
else asyncTask -> | |
log "done with task" | |
ask() | |
ask() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment