Q.js手册

进度通知

It's possible for promises to report their progress, e.g. for tasks that take a long time like a file upload. Not all promises will implement progress notifications, but for those that do, you can consume the progress values using a third parameter to then:

return uploadFile()
  .then(function () {
    // Success uploading the file
  }, function (err) {
    // There was an error, and we get the reason for error
  }, function (progress) {
    // We get notified of the upload's progress as it is executed
  });

Like fail, Q also provides a shorthand for progress callbacks called progress:

return uploadFile().progress(function (progress) {
    // We get notified of the upload's progress
});