Good stuff. I'm really looking forward to digging through this.
-TJ On 7/21/06, Seth Dillingham <[EMAIL PROTECTED]> wrote:
Hey all, A couple months ago I was working on a pretty complex app that uses Prototype.js very heavily. In the process I came up with a way to use Prototype to produce custom events, reliably, in javascript. By "custom events" I mean stuff like "message received" and "results available" and "progress update", not browser events like click and mouseover. I showed it to Sam (you know, *THE Sam*, our Sam) at RubyConf last month, and he got pretty excited. We skipped one of the sessions, sat down in the lobby, and went over the whole thing for an hour. He liked it. I've even received ONE WHOLE EMAIL from him on the topic, since then. ;-) The JS events stuff have been extracted from the project so they can be used by others (people or projects). ** It's all written up in a longish article (long because of the sample code), here: <http://www.truerwords.net/articles/web-tech/custom_events.html> ** There are links on the page to a useless demo app, and all of the actual code. Let me warn you that there's a lot there, BUT you don't need all of it if you want to play with it! I included an "even tracing" module to help with debugging, and an optional event broker (which is explained in the article). The most important parts are all in one file, and are only about 4 kb. The basic idea is that you have event publishers and event subscribers (listeners). Any class or object in your app can be either or both. Listeners subscribe to publishers for the events they want to receive, publishers remain ignorant of who is listening. If you mix in an Event Broker class as well, then the listeners don't even need to know about the event publishers... they just tell the broker that they care about all events of a particular type, and they'll receive them regardless of which publisher produced it. (This is handy in cases where you have a large collection of publishers, or when you may not know what objects have been included on the page.) OK, this is more than long winded enough. It's all explained in the article. Seth P.S. This custom events code is a pretty thorough solution... so yes, I realize it's not for everyone, but I thought it might be useful for some people on the list. At least it's "on-topic"! _______________________________________________ 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