-
-
Save Raynos/c664833ae7b56ab48534 to your computer and use it in GitHub Desktop.
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
function selectron() { | |
var sel = new EventEmitter() | |
, selected | |
sel.select = select | |
sel.unselect = unselect | |
return sel | |
function select(thing) { | |
unselect() | |
selected = thing | |
selected.select() | |
sel.emit("select", selected) | |
} | |
function unselect() { | |
if (selected) { | |
selected.unselect() | |
} | |
sel.emit("unselect", selected) | |
selected = null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment