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 -~----------~----~----~----~------~----~------~--~---