I've never programmed with such "global" events, but I like the idea
very much and can think of several places it could be useful in my own
projects. However, I don't think adding this functionality on top of
Prototype's Event is a good idea. Just like Tobias suggested to me on
my Event patch, add the new functionality in it's own class since it
really is different functionality altogether. This will avoid
confusion with the existing Event.observe API and keep the code
cleaner.  I'd suggest something like "Message" or (I just looked up
dojo's API) "Topic".

Example API:
//in the vein of Ajax.Responders, this should already be familiar to
Protoype users
  onStart: loader.onCallbackStart,
  onEnd: loader.onCallbackEnd

// subscribe to an event topic
Topic.subscribe('testEvent', function(){
  alert('testEvent called with '+arguments.length+' arguments');

// publish the event to all subscribers
Topic.publish('testEvent', {bar:'foo'});

Of course you can use whatever names for the class and methods you
like, my point is just that this should be a separate API altogether.
This will let you avoid passing null parameters, etc..
Also, I suggest that registering an event name before using it *not*
be required, there is simply no need to.

What do you think of my suggestions?


You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to