I'm trying to find the most graceful way to distinguish between single and double clicks in Bacon.js, but I feel like I'm not completely grasping how this works. The following works for detecting a double-click, but I'm a bit stumped as to how I would specify different behavior (i.e., a different callback function) elegantly for a single-click event.
clicked = Bacon.fromEventTarget(document, "click")
clicked.bufferWithTimeOrCount(300, 2)
.filter((x) -> x.length is 2)
.onValue (x) ->
console.log "double clicked: ", x