Last active
December 15, 2015 21:49
-
-
Save jiahut/5328797 to your computer and use it in GitHub Desktop.
Deferred notify and progress Callbacks
This file contains hidden or 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 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)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
当延迟对象更新后(rejected/resolved)任何新增加的过程回调(progressCallbacks)会立即执行,并且传递最后一次notify 时传递的参数,而忽然后面的notify,当然也忽然了参数
ref: http://www.oschina.net/translate/what-is-the-point-of-promises