Skip to content

Instantly share code, notes, and snippets.

@Nek

Nek/index.js

Created Feb 5, 2014
Embed
What would you like to do?
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
You can’t perform that action at this time.