Skip to content

Instantly share code, notes, and snippets.

@arikon
Created November 24, 2013 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arikon/7627430 to your computer and use it in GitHub Desktop.
Save arikon/7627430 to your computer and use it in GitHub Desktop.
deffered.notify() / promise.progress() test
var Q = require('q');
Q.thenResolve()
.then(function() {
var d = Q.defer(),
step = 0;
var interval = setInterval(function() {
d.notify('step ' + ++step);
}, 1000);
setTimeout(function() {
clearInterval(interval);
d.resolve();
}, 10000);
return d.promise;
})
.then(function() {
console.log('Done');
})
.progress(function(data) {
console.log('Progress:', data);
});
@arikon
Copy link
Author

arikon commented Nov 24, 2013

Tested with q@0.9.7.

This will output:

$ node q-progress.js
Progress: step 1
Progress: step 2
Progress: step 3
Progress: step 4
Progress: step 5
Progress: step 6
Progress: step 7
Progress: step 8
Progress: step 9
Done

So, progress messages are bubbling through the promise chain as rejection messages do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment