[mochikit] Re: disconnecting all signals to an object

2006-08-31 Thread Jaime Cham

Done, ticket #175


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: disconnecting all signals to an object

2006-08-30 Thread Beau Hartshorne

On 29-Aug-06, at 4:25 PM, Jaime Cham wrote:

> It seems that it's a useful usage to disconnect all signals going  
> TO an
> object. For example, when the an object that connects itself to  
> several
> signals or events is destroyed, in order to ensure correct recovery of
> the memory it would want to disconnect itself.
>
> I use the following extra code for MochiKit.Async:
>
> MochiKit.Base.update(MochiKit.Async, {
>   disconnectAllTo: function (objOrFunc, funcOrStr /* optional */) {
>   if (typeof(objOrFunc) != 'object') {
>   throw new Error("need to specify a receving object");
>   }
> var self = MochiKit.Signal;
> var observers = self._observers;
>   var i = 0;
>   while (i < observers.length) {
>   var ident = observers[i];
>   if (ident[4] == objOrFunc
>   && (typeof(funcOrStr) == 'undefined'
>   || ident[5] == funcOrStr)
>   ) {
>   self._disconnect(ident);
>   observers.splice(i, 1);
>   }
>   else
>   i++;
>   }
> },
> });
> disconnectAllTo = MochiKit.Async.disconnectAllTo;
>
> Is there already a different way of doing this? or am I violating some
> signal/slot design principle?
>

I can see how this would be useful. It probably belongs to Signal,  
not Async. Could you please submit a ticket asking to include this,  
and attach your code as a .js file?

Thanks!
Beau


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---