Skip to content

Instantly share code, notes, and snippets.

@tailhook
Created January 13, 2015 21:33
Embed
What would you like to do?
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