Created
June 27, 2015 07:52
-
-
Save mu-777/9964c04c916fd83ca6a7 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
var Q = require('q'), | |
defered = Q.defer(), | |
promise = defered.promise; | |
function heavyProcess(defered){ | |
setTimeout(function(){ | |
console.log('finish!') | |
defered.resolve('end') | |
}, 5000); | |
} | |
promise.then(function(msg){ | |
console.log(msg) | |
}); | |
heavyProcess(defered); | |
//// after 5 sec, console logged | |
// finish! | |
// end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment