views:

111

answers:

1

In the PureMVC framework, Proxies communicate with the ApplicationFacade (and thus any interested components) via a Notification. Should this Notification be sent via their own instance, or the Singleton instance of the ApplicationFacade? Frankly, does it matter?

Here are two ways of doing this (in Flex/AS):

// from the proxy itself
this.sendNotification(ApplicationFacade.NOTIFY_ALL);

// via the ApplicationFacade instance
ApplicationFacade.getInstance().notifyObservers(new Notification(ApplicationFacade.NOTIFY_ALL));

The second method looks more verbose and less intuitive to me. Moreover, the Proxy has the ability to send Notifications, which, in my mind, means it probably should. Are there instances where the Proxy should only send a Notification via the ApplicationFacade instance?

+2  A: 

The notifyObservers function is part of an older implementation; the sendNotification call from the proxy is the acceptable method. Pretty sure that the notify function is just for backwards compatibility. Actually (just poked into the code): the sendNotification method of a class that implements INotifier merely calls facade.sendNotification, which, in turn, calls facade.notifyObservers, so the second method is the same as the first - it's just more verbose as you pointed out. So, yeah: first!

Typeoneerror
Thanks for your input -- makes sense :)
bedwyr