This seems like a Good Thing :)
I think it would gain more acclaim with just a slight test-code page *hint hint*

Andreas

On Aug 18, 2006, at 15:34 , Brandon Aaron wrote:

Here is what I've been using for custom events in my projects.
It is pretty straight forward and small.
http://www.brandonaaron.net/prototype/src/event.custom.js

You create an event like this:

var onMyEvent = new Event.Custom('myEvent'[, someObject || window]);

The first param is the name of the event, it defaults to
'customEvent'. The second param is global scope correction for all
observers. It defaults to window.

Then you can attach observers to it like this:

onMyEvent.observe(function(event[, extra, params]) { /*...*/ }[,
override scope || event scope ]);

You can detach an observer by replacing observe in the previous
example with stopObserving. I would suggest using the scope override
instead of bind to properly stopObserving functions without having to
create handlers for your observers.

You can fire the event like this:

onMyEvent.fire(eventObject[, param1, param2 /*... */]);

The eventObject is something you would create ... by default it will
contain a name property and has the name of the event when you created
it. The fire method can take any number of extra params that will be
passed onto the observers.

You can unsubscribe all observers by calling onMyEvent.unsubscribeAll()

Let me know if you use it and if it works for you. I just recently
rewrote it ... so let me know if you run into any bugs.

Brandon

On 8/17/06, Seth Dillingham <[EMAIL PROTECTED]> wrote:
On 8/17/06, Brian Feliciano <[EMAIL PROTECTED]> wrote:
> Hi guys!
> i know prototype can create custom events and can subscribe to it, but is
> there already a library for this?

<http://www.truerwords.net/articles/web-tech/custom_events.html>
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

______________________

Andreas Wahlin
Webbutvecklare

Webbhuset AB
Östra Hamngatan 45, 411 10 Göteborg

Telefon: 031-339 19 19, Direkt: 031-739 18 20, Fax: 031-711 12 20
www.webbhuset.se



Privileged/confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by a reply email. Thank you.


_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to