PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: sasuke on October 24, 2009, 12:29:28



Title: Why not emulate Events?
Post by: sasuke on October 24, 2009, 12:29:28
Hi all,

I was wondering as to why the concept of Notifications[publish/subscribe model] was used to implement async event handling? I mean, isn't it possible to actually emulate the Event handling framework already present in Flex,Java and provide a thin portable wrapper around them?

I did hear a while back that Cliff had some issues/complaints with the way event handling worked in AS3 and other languages and wanted to implement some other scheme. I'd like to hear as to what really went wrong with events and what architectural decisions/points were taken into consideration before going with Notification and not Events. Links/Articles/other references purporting the point would be awesome. :)

TIA,
sasuke


Title: Re: Why not emulate Events?
Post by: puremvc on October 25, 2009, 10:19:00
The number one thing I dislike about Flash Events is that I can't send arbitrary data with the base event class. Sure I could've written a PureMVCEvent subclass with an object as a payload, but internally to PureMVC, I wanted a publish/subscribe system, the beauty of which is that the subscriber need not have a reference to the publisher in order to receive the notification. (i.e. thingIHaveARefTo.addEventListner()). Also, Flash defines the Event class, not ActionScript and by this juncture I was already sure I wanted to remain platform neutral, because AS3 was slated to become the next JavaScript at the time (via Mozilla's Tamarin project).

The notification system as implemented in PureMVC complements the event system in Flash, it's not meant to be a replacement for events. It operates in a fundamentally different way. For a detailed discussion of Events vs. Notifications, see page 13 of the PureMVC Best Practices document:

http://puremvc.org/component/option,com_wrapper/Itemid,174/

-=Cliff>