I don't think I understand the use case where this type of thing would
come to use. Could you please provide a scenario? Is it useful in
libraries? Or widgets? Or webapps?

Otherwise, here is a quick review without much thought:

1. Using just "signal.apply" instead of "MochiKit.Signal.signal.apply"
causes problems if not exporting functions.

2. It might be unexpected by users that connecting to anySource and
anySignal, will only receive signals that are manually sent via the
signal() function. I.e. not the DOM signals.

3. The addition of these generic objects impose a penalty on all
manual signal sending, something which might not be desired. We should
probably look for minimizing the impact a bit here, I think.

4. The MochiKit.Signal.anySource and MochiKit.Signal.anySignal names
should perhaps be upper-case as they are constants. Also, for a user
it might be clearer to use something like null or undefined instead of
a constant from MochiKit.Signal.

Anyway. These were just a couple of random thoughts. I'm all for
finding ways to make it even easier to work with signals and
especially deferreds.

Cheers,

/Per

On Wed, Nov 5, 2008 at 2:15 PM, Giulio Cesare Solaroli
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have just created a patch (attached) for the current MochiKit.Signal
> implementation to achieve something very similar to the former
> NotificationCenter.
>
> I have also updated the relative tests.
>
> I have not updated the documentation yet, but if you consider
> including the patch into the repository, I will be pleased to update
> the documentation too.
>
> Any feedback is welcome.
>
> Best regards,
>
> Giulio Cesare
>
>
> On Wed, Nov 21, 2007 at 11:32 AM, Giulio Cesare Solaroli
> <[EMAIL PROTECTED]> wrote:
>> Here you are:
>> http://clipperz.googlecode.com/svn/trunk/src/js/Clipperz/NotificationCenter.js
>>
>> Sorry again for the trouble.
>>
>> Feel free to ask for any question.
>>
>> Best regards,
>>
>> Giulio Cesare
>>
>>
>> On 11/21/07, Giulio Cesare Solaroli <[EMAIL PROTECTED]> wrote:
>>> Sorry!!!! My fault. :-(
>>>
>>> I must have screwed something on the build script.
>>>
>>> I will try to fix it as soon as possible. If you want to take a look
>>> at the code in the meanwhile, the same code could be found buried with
>>> the full source of our application (the code of the application is
>>> released with a "reference licence", not with the BSD licence used for
>>> the crypto library).
>>>
>>> You can find the link to the code and details on the licence here:
>>> http://www.clipperz.com/learn_more/reviewing_the_code
>>>
>>> I will post back as soon as I managed to commit the NotificationCenter
>>> into the code.google SVN repository.
>>>
>>> Sorry for the trouble.
>>>
>>> Best regards,
>>>
>>> Giulio Cesare
>>>
>>>
>>>
>>> On 11/21/07, Per Cederberg <[EMAIL PROTECTED]> wrote:
>>> >
>>> > Ehm... I couldn't find the NotificationCenter class anywhere in the
>>> > svn repo. Perhaps I'm looking at the wrong place? Found a reference
>>> > to the class here, but no source code:
>>> >
>>> > http://clipperz.googlecode.com/svn/trunk/src/js/Clipperz/Crypto/PRNG.js
>>> >
>>> > /Per
>>> >
>>> > On Nov 15, 1:50 pm, "Giulio Cesare Solaroli" <[EMAIL PROTECTED]>
>>> > wrote:
>>> > > Hello,
>>> > >
>>> > > I have implemented a NotificationCenter class similar to the one
>>> > > available on the MacOSX foundation library (rooted back in the NeXT
>>> > > NSFoundation library).
>>> > >
>>> > > The NotificationCenter allows loosely binding between notifying
>>> > > objects and listeners, and it is included in the open source crypto
>>> > > library we have released as part of our project.
>>> > >
>>> > > There is no documentation, but the code should be quite clean, and
>>> > > there are some automatic tests where you should get some ideas on how
>>> > > to use it. For any other question, feel free to contact me.
>>> > >
>>> > > You can find the library here:
>>> > > -http://code.google.com/p/clipperz
>>> > >
>>> > > If you are interested on our project, you can find all the details here:
>>> > > -http://www.clipperz.com
>>> > >
>>> > > Hope this helps.
>>> > >
>>> > > Regards,
>>> > >
>>> > > Giulio Cesare
>>> > >
>>> > > On Nov 15, 2007 12:30 PM, Zsolt <[EMAIL PROTECTED]> wrote:
>>> > >
>>> > >
>>> > >
>>> > > > I needed the ability to have two or more objects of the same type talk
>>> > > > to each other and respond to each others events. For example when one
>>> > > > gets updated the other one should also do something. My first thought
>>> > > > was to use MochiKit.Signal.signal but that needs a source as a first
>>> > > > arg so that is not good because i do not know the name of the other
>>> > > > object so i modified signal and came up with
>>> > >
>>> > > > MochiKit.Base.update(MochiKit.Signal,{
>>> > > >         'signalAll' : function(sig){
>>> > > >                 var self= MochiKit.Signal;
>>> > > >                 var observers = self._observers;
>>> > > >                 var args = MochiKit.Base.extend(null, arguments, 1);
>>> > > >                 var errors = [];
>>> > > >         self._lock = true;
>>> > > >         for (var i = 0; i < observers.length; i++) {
>>> > > >             var ident = observers[i];
>>> > > >             if (ident.signal === sig && ident.connected) {
>>> > > >                 try {
>>> > > >                     ident.listener.apply(ident.source, args);
>>> > > >                 } catch (e) {
>>> > > >                     errors.push(e);
>>> > > >                 }
>>> > > >             }
>>> > > >         }
>>> > > >                 self._lock = false;
>>> > > >         if (self._dirty) {
>>> > > >             self._dirty = false;
>>> > > >             for (var i = observers.length - 1; i >= 0; i--) {
>>> > > >                 if (!observers[i].connected) {
>>> > > >                     observers.splice(i, 1);
>>> > > >                 }
>>> > > >             }
>>> > > >         }
>>> > > >                 if (errors.length == 1) {
>>> > > >             throw errors[0];
>>> > > >         } else if (errors.length > 1) {
>>> > > >             var e = new Error("Multiple errors thrown in handling
>>> > > > 'sig', see errors property");
>>> > > >             e.errors = errors;
>>> > > >             throw e;
>>> > > >         }
>>> > > >         }
>>> > > > });
>>> > >
>>> > > > Basicly you can now just call MochiKit.Signal.signalAll('onupdate');
>>> > > > and every object connected to that signal will get notified.
>>> >
>>> > >>> >
>>> >
>>>
>>
>

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to