Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Why not emulate Events?  (Read 6417 times)
sasuke
Full Member
***
Posts: 29


View Profile Email
« 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
« Last Edit: October 25, 2009, 10:22:21 by puremvc » Logged
Pages: [1]
Print