Created
August 5, 2014 14:08
-
-
Save xujihui1985/f6ab292b494adb45cf7d to your computer and use it in GitHub Desktop.
asyncwithgenerator.js
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
function request(url) { | |
// this is where we're hiding the asynchronicity, | |
// away from the main code of our generator | |
// `it.next(..)` is the generator's iterator-resume | |
// call | |
makeAjaxCall( url, it.next.bind(it) ); | |
// Note: nothing returned here! | |
} | |
//otherwise I got Method Generator.prototype.next called on incompatible receiver undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment