prev record
[2010.05.19.수요일] pureMVC Mediator
zimamdero
2013. 7. 14. 19:39
Mediator는 UI와 직접적인 연관이 있다. 쉽게 생각하면 화면에 보여지는 view를 다룬다고 생각하면된다.
facade.registerMediator(new ModetureMediator(note.getBody() as Stage));
facade.registerMediator(new LocationMediator(note.getBody() as Stage));
facade.registerMediator(new DropMenuMediator(note.getBody() as Stage));
실제로 작동하기 위해서 위 처럼 facade에 등록 되어야한다. note.getBody() as Stage 는 Mediator 가 참조할 vviewComponent인데, 지금 command에 등록되어 notification에 의해 stage를 viewComponent로 받고 있는 것이다.
override public function listNotificationInterests():Array{
return[ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE];
}
override public function handleNotification(note:INotification):void{
switch(note.getName()) {
case ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE:
var l_modeture:ModetureComp = new ModetureComp();
l_modeture.setStage(_viewComp);
break;
}
}
Mediator 안에서 중요한 것이 위의 두 메서드 listNotificationInterests()와 handleNotification(note:INotification) 이다. ㅣistNotificationInterests()는 보내지는 notification 중에 받아서 반응해야할 notification을 등록하는 것이다. 즉 ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE 가 보내지게 되면 switch문을 통해 이 notification 에 따른 특별한 행동을 하게 하는 것이다.
주의해야할 것은 처음에 facade에 등록할때의 순서가 mediator 가 notification을 받는데 영향을 미친다는 것이다. facade에 등록된 순서에 따라 listNotificationInterests()에 등록된 notification이 전달되지 않을 수도 있다. notification이 전달되지 않는 상황이 발생하면 이를 꼭 확인해야한다.
facade.registerMediator(new ModetureMediator(note.getBody() as Stage));
facade.registerMediator(new LocationMediator(note.getBody() as Stage));
facade.registerMediator(new DropMenuMediator(note.getBody() as Stage));
실제로 작동하기 위해서 위 처럼 facade에 등록 되어야한다. note.getBody() as Stage 는 Mediator 가 참조할 vviewComponent인데, 지금 command에 등록되어 notification에 의해 stage를 viewComponent로 받고 있는 것이다.
override public function listNotificationInterests():Array{
return[ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE];
}
override public function handleNotification(note:INotification):void{
switch(note.getName()) {
case ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE:
var l_modeture:ModetureComp = new ModetureComp();
l_modeture.setStage(_viewComp);
break;
}
}
Mediator 안에서 중요한 것이 위의 두 메서드 listNotificationInterests()와 handleNotification(note:INotification) 이다. ㅣistNotificationInterests()는 보내지는 notification 중에 받아서 반응해야할 notification을 등록하는 것이다. 즉 ConstsClass.NOTI_XML_LOAD_AND_SET_PROXYS_COMPLETE_MODETURE 가 보내지게 되면 switch문을 통해 이 notification 에 따른 특별한 행동을 하게 하는 것이다.
주의해야할 것은 처음에 facade에 등록할때의 순서가 mediator 가 notification을 받는데 영향을 미친다는 것이다. facade에 등록된 순서에 따라 listNotificationInterests()에 등록된 notification이 전달되지 않을 수도 있다. notification이 전달되지 않는 상황이 발생하면 이를 꼭 확인해야한다.