Last active
December 14, 2015 20:39
-
-
Save ukyo/5145740 to your computer and use it in GitHub Desktop.
http://www.slideshare.net/uupaa/flowjs のjQuery.Deferredの使い方はそもそもおかしい。
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
| waitForAsyncProcesses().done(finishedCallback); | |
| function waitForAsyncProcesses() { | |
| var asyncFunc, A, B, C, D; | |
| asyncFunc = function(ms) { | |
| var dfd = $.Deferred(); | |
| setTimeout(dfd.resolve, ms); | |
| return dfd.promise(); | |
| }; | |
| A = asyncFunc.bind(null, 10); | |
| B = asyncFunc.bind(null, 100); | |
| C = asyncFunc.bind(null, 20); | |
| D = asyncFunc.bind(null, 200); | |
| return $.when( | |
| $.when(A(), B()), | |
| $.when(C(), D()) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment