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: How's sendNotification() different from flash's dispatchEvent() ?  (Read 5404 times)
Vishwas
Jr. Member
**
Posts: 12


View Profile Email
« on: November 13, 2011, 01:21:07 »

Puremvc uses sendNotification to broadcast it's events. How is it different from dispatchEvent ?

thanks
V.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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.

Logged
Pages: [1]
Print