On 11/28/06, Jason Bunting <[EMAIL PROTECTED]> wrote: > > > On the wiki at http://trac.mochikit.com/wiki/connectOnce there is this > implementation for a function that mimics 'connect' except it disconnects > after the signal fires once (copied from wiki): > > 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) > } > > Just trying to figure out if this is an equivalent implementation (it seems > to work, but just want to double-check): > > function connectOnce(src, signal, dest, func) { > var connectionId = connect(src, signal, dest, func); > connect(src, signal, function() { > disconnect(connectionId); > }); > }
There aren't any ordering guarantees for signals firing. It's possible that under some circumstances the disconnect will fire before the intended signal. -bob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~----------~----~----~----~------~----~------~--~---
