开发者

Flex: static var or use flexGlobals.topLevelApplication?

开发者 https://www.devze.com 2023-03-14 08:55 出处:网络
In Flex 4, if I have something like user information that I want to be able to access from anywhere in the application, is it better开发者_JAVA百科 to create a class with static var for the info or to

In Flex 4, if I have something like user information that I want to be able to access from anywhere in the application, is it better开发者_JAVA百科 to create a class with static var for the info or to have the variables in the top level application and access via flexGlobals.topLevelApplication?


Creating class with a static var is more preferable from the architecture point of view than coupling your client class with your top level application implementation. But the best way is to inject value in your client instance using delegation or dependency injection library/framework.

0

精彩评论

暂无评论...
验证码 换一张
取 消