Last active
August 29, 2015 14:12
-
-
Save sunwukung/69c1be92215112e93a87 to your computer and use it in GitHub Desktop.
kefir event listener question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// domStreams | |
var K = require("kefir") | |
, exported = {} | |
, evts = ["click", "mouseenter", "mousemove", "mouseexit"]; | |
evts.forEach((eventKey, i, arr) => { | |
exported[eventKey] = (elem) => { | |
return K.fromEvent(elem, eventKey); | |
}; | |
}); | |
// UI | |
var rootNode = document.querySelector("#foo") | |
, mousemoveStream = domStreams.mousemove(rootNode) | |
, hits = 0; | |
mousemoveStream.onValue(() => { | |
hits++; | |
console.log("still firing the on value method"); | |
if (hits === 100) { | |
console.log("removing the value output"); | |
mousemoveStream.off(); // should end messages? | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated: