Skip to content

Instantly share code, notes, and snippets.

@jiahut
Last active December 15, 2015 21:49
Show Gist options
  • Save jiahut/5328797 to your computer and use it in GitHub Desktop.
Save jiahut/5328797 to your computer and use it in GitHub Desktop.
Deferred notify and progress Callbacks
var dfd = $.Deferred();
dfd.progress(function(arg){ console.log(arg,1)});
dfd.notify('this is first time notify:I am jazz')
dfd.progress(function(arg){ console.log(arg,2)});
dfd.notify('this is second time notify: I love this game');
dfd.reject('sorry,badthing arise');
dfd.progress(function(arg){ console.log(arg,3)});
dfd.notify("this is third time notify: I will come back ?")
dfd.progress(function(arg){ console.log(arg,4)});
@jiahut
Copy link
Author

jiahut commented Apr 7, 2013

当延迟对象更新后(rejected/resolved)任何新增加的过程回调(progressCallbacks)会立即执行,并且传递最后一次notify 时传递的参数,而忽然后面的notify,当然也忽然了参数
ref: http://www.oschina.net/translate/what-is-the-point-of-promises

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