/etc/environment,/etc/profile, .profile, .env详解
2012-05-03 19:17
260 查看
Yeah.
As the best practice says: the command and event should be One-To-One in cairngorm . If doing so, we would have lots of command and event files.
So here is my way in solving the problem, see codes below.
PhotoEvent.as has two event types.
PhotoCommand.as deal with PhotoEvent; PhotoServiceDelegate.as contains HTTPService Call.
My Question is : the way I hold PhotoEvent and reuse it in result function is right ?
is there any advice ?
As the best practice says: the command and event should be One-To-One in cairngorm . If doing so, we would have lots of command and event files.
So here is my way in solving the problem, see codes below.
PhotoEvent.as has two event types.
import com.adobe.cairngorm.control.CairngormEvent; import com.babytree.photoUpload.control.MainController; public class PhotoEvent extends CairngormEvent { public function PhotoEvent (type:String) { super(type); } //get all albums of a user public static const GET_ALBUMSLIST:String = "get_albumslist"; //get all photos of an album public static const GET_ALBUMPHOTOS:String = "get_albumphotos"; }
PhotoCommand.as deal with PhotoEvent; PhotoServiceDelegate.as contains HTTPService Call.
public class PhotoCommand implements ICommand,IResponder { private var model : ModelLocator = ModelLocator.getInstance(); private var photoServiceDelegate:PhotoServiceDelegate; private var photoEvent:PhotoEvent; // functions ============================ public function execute( event:CairngormEvent ) : void { photoEvent = event as PhotoEvent; photoServiceDelegate = new PhotoServiceDelegat(this as IResponder); switch(photoEvent.type){ case PhotoEvent.GET_ALBUMSLIST: photoServiceDelegate.getUserAlbums(model.userVO); break; case PhotoEvent.GET_ALBUMPHOTOS: photoServiceDelegate.getAlbumPhotos(model.userVO); break; } } public function result( data:Object ) : void { switch(photoEvent.type){ case PhotoEvent.GET_ALBUMSLIST: //do something break; case PhotoEvent.GET_ALBUMPHOTOS: //do something break; } } public function fault( info : Object ) : void { trace("fault in PhotoCommand.as ==== Event.type is ===" + photoEvent.type); } }
My Question is : the way I hold PhotoEvent and reuse it in result function is right ?
is there any advice ?
相关文章推荐
- 修改/etc/profile和/etc/environment导致图形界面无法登陆的问题
- ubuntu /etc/profile和/etc/environment的比较
- /etc/profile和/etc/environment的比较
- ubuntu /etc/profile和/etc/environment的比较
- /etc/environment 和 /etc/profile
- etc/profile和/etc/environment的比较
- Linux /etc/environment和/etc/profile
- /etc/profile和/etc/environment的比较
- /etc/profile 与 /etc/environment
- etc/profile和/etc/environment的比较 (转载)
- etc/profile和/etc/environment的比较
- /etc/profile和/etc/environment的比较
- ubuntu /etc/profile和/etc/environment的比较
- /etc/profile,/etc/environment,.bash_profile及.bashrc等与环境变量有关的文件的比较
- /etc/profile和/etc/environment的比较
- /etc/profile和/etc/environment的比较
- Ubuntu下的/etc/profile,/etc/environment,/etc/bashrc和~/.bashrc
- /etc/profile、~/.bashrc、/etc/bashrc、~/.bash_profile、 ~/.bash_login、 ~/.profile、/etc/environment
- ubuntu /etc/profile和/etc/environment的比较 (转载)
- /etc/profile和/etc/environment的比较