Sometimes you want a Signal to only fire once then be disconnected - onmouseup for the document at the end of a dragging operation, assigning one-off click operations to areas of the page. So below is a function with the same signature as MochiKit.Signal.connect that automatically disconnects the function when called. This saves keeping a reference to the signal around to pass to disconnect

function connectOnce(src, signal, dst, func) {
        var S = MochiKit.Signal
        var d
        if (typeof(func) == 'undefined') {
                func = dst
        } else {
                func = MochiKit.Base.method(dst, func)
        }
        var wrapper = function() {
                func.apply(this, arguments)
                S.disconnect(d)
        }
        d = S.connect(src, signal, wrapper)
}