-
-
Save modernserf/11149833 to your computer and use it in GitHub Desktop.
This file contains 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
// using asynquence+iterable sequences | |
var domready; | |
ASQ() | |
// wait for `domready` before we proceed | |
.seq( domready = ASQ.iterable() ) | |
.gate( | |
requestJSON( "foo.json" ), | |
requestJSON( "bar.json" ) | |
) | |
.val( transformJSONs ) | |
.seq( uploadJSON ) | |
.seq( displayRecords ) | |
.or( handleError ); | |
$(document).ready( domready.next ); |
This file contains 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
// using native promises | |
var domReady = new Promise($); | |
domReady.then(function (){ | |
return Promise.all([ | |
requestJSON( "foo.json" ), | |
requestJSON( "bar.json" ) | |
]); | |
}).then(transformJSONs) | |
.then(uploadJSON) | |
.then(displayRecords) | |
.catch(handleError); | |
// see http://jsfiddle.net/modernserf/TyuPA/2/ for working code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment