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?
The
notifyObserversfunction is part of an older implementation; thesendNotificationcall from the proxy is the acceptable method. Pretty sure that the notify function is just for backwards compatibility. Actually (just poked into the code): thesendNotificationmethod of a class that implementsINotifiermerely callsfacade.sendNotification, which, in turn, callsfacade.notifyObservers, so the second method is the same as the first – it’s just more verbose as you pointed out. So, yeah: first!