Skip to content

Instantly share code, notes, and snippets.

@xujihui1985
Created August 5, 2014 14:08
Show Gist options
  • Save xujihui1985/f6ab292b494adb45cf7d to your computer and use it in GitHub Desktop.
Save xujihui1985/f6ab292b494adb45cf7d to your computer and use it in GitHub Desktop.
asyncwithgenerator.js
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