-
-
Save Raynos/2f990fc882437fd358d5 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
var set = Set() | |
, sorted = sortable() | |
set.on("add", function (obj) { | |
var place = sorted.create() | |
, widget = Widget(obj, place) | |
widget.on("change", place.updateValue) | |
place.updateValue(widget.value()) | |
}) | |
function Widget(obj, place) { | |
var elem = makeElement() | |
, widget = new EventEmitter() | |
databind(elem, obj) | |
place.append(elem) | |
obj.on("end", function () { | |
place.destroy() | |
}) | |
obj.on("changes", function (changes) { | |
if (changes.value) { | |
widget.emit("change", changes.value) | |
} | |
}) | |
widget.value = function () { | |
return obj.get("value") | |
} | |
return widget | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment