Skip to content

Instantly share code, notes, and snippets.

@Nek
Created February 5, 2014 20:03
Show Gist options
  • Save Nek/8831891 to your computer and use it in GitHub Desktop.
Save Nek/8831891 to your computer and use it in GitHub Desktop.
broken code
function *listen(el, evType) {
while (true)
yield function(cb) {
var fire = function(ev) {
el.removeEventListener(evType, fire);
cb(null, ev);
}
el.addEventListener(evType, fire);
}
}
var gens = require('gens');
function go(gen) {
gens(gen)(function(err) { if (err) throw err; });
}
go(function*() {
var clicks = listen(document.getElementById('search'), 'click');
while (true)
console.log(clicks.next().value);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment