Skip to content

Instantly share code, notes, and snippets.

@tailhook
Created January 13, 2015 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tailhook/c76f1bdf4533d8564fb8 to your computer and use it in GitHub Desktop.
Save tailhook/c76f1bdf4533d8564fb8 to your computer and use it in GitHub Desktop.
JS generators
function generator() {
var result = yield "http://google.com";
console.log(result)
}
var gen = generator()
var url = gen.next()
var req = new XMLHTTPRequest(url)
req.ondocumentstatechage = function(resp) {
gen.next(resp.responseText)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment