PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: Vishwas on November 13, 2011, 01:21:07



Title: How's sendNotification() different from flash's dispatchEvent() ?
Post by: Vishwas on November 13, 2011, 01:21:07
Puremvc uses sendNotification to broadcast it's events. How is it different from dispatchEvent ?

thanks
V.


Title: Re: How's sendNotification() different from flash's dispatchEvent() ?
Post by: puremvc on November 13, 2011, 04:17:49
With events, a class that want's to listen for an event must have a reference to the object it wants to add the event listener.

Not so with notifications (or notes for short). When a mediator is registered, it is interrogated (has its listNotifications method called) by the framework. It need only return a list of the notes it is interested in receiving. This is more like a publish/subscribe system. Also a command can be registered to a given note name, and it will be instantiated and executed and passed the notification. Again, it had no reference to the sender, in fact it doesn't even exist until after the note is sent.