The use I have for it is for storing user credentials, and calling a transfer object that functions as a sort of "cache" for the current session in all of the flex modules.
Thinking about objects that have to be present in every module. Is开发者_StackOverflow there any alternative to a singleton instance for this?
Yes! Automated dependency injection frameworks, such as Mate, Robotlegs, Parsley, or Swiz. Check out http://www.developria.com/2010/06/robotlegs-for-framework-beginn.html and http://www.developria.com/2010/05/mate-for-framework-beginners.html for a more in-depth look about how two of these work.
For just a few reasons you should avoid Singletons, see http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars
精彩评论