Ok, I have to post a bit of a retraction. While EventDispatcher is still a big improvement over previous event models, it's not quite as cool as I thought it was at 3am last night. Nothing ever looks quite as hot the morning after, does it?
The ability to subscribe functions or methods to events is made vastly less useful than I excitedly thought last night by the fact that the function will, of course, be executed within the scope of the object dispatching the event (duh). This means that really, this approach is only about as useful as a callback event handler (the functionality is virtually identical) - its occasionally handy for quick'n'dirty prototyping, but usually not good form.
Ahh... the murky clarity of 3am experimentation. Oh well, stay tuned, I hope to build out an extended version of the eventDispatcher that includes some nifty new tricks.
Comments (5)
check your previous blog entry on this subject. I posted what I wrote a while back. its the eventdispatcher, plus it allows you to define the object and method you wish to call if you want. it also lets you pass args (despite being less OOP in this manner)
Posted by: Kenny Bunch at September 25, 2003 10:23 AMURL:
Have you taken a look at Mach-II which morphed as an 'OO' framework from Fusebox? I do realize at this point most samples etc on written for CFMX.
Posted by: Mike Brunt at September 25, 2003 10:58 AMURL: http://www.webapper.net
ahh, morning Afters..:p
Posted by: Funkatron at September 25, 2003 11:57 AMURL:
I think it's great because you can call public methods on the dispatcher from another object without explicitly calling the object. Does it break OO if you do this from a view that knows nothing of a model? Even if it does I think this functionality is great. AsBroadcaster couldn't do it.
Posted by: Mike Britton at September 28, 2003 11:11 AMURL:
How about using delegates?
Posted by: rasheed at November 21, 2004 07:36 PMI assume the use of delegates so I simply extended eventDispatcher to take two forms of addlistener, one with a delegate and the original form uses arguments.callee and builds a delegate on the fly. - most times, the target object is the same one adding a listener.
URL: