Skip to content

Instantly share code, notes, and snippets.

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