forwarding custom events from view
I have some events that i dispatch in my view, now I also want
to use this custom events outside of the view in a command.
What I came up with is a forward function, that dispatches the
event again:
my Mediator:
public override function onRegister():void {
addViewListener( SomeEvent.TYPE, forward )
addViewListener( SomeOtherEvent.TYPE, forward )
...
}
public function forward(e:Event):void {
dispatch(e.clone())
}
this works, but seems kinda wrong.
So, is this best practice or how would you "forward" these
events?
Or should I listen to the flash-events that the gui throws (mostly
MouseEvent.CLICK...) and create my events in the mediator (which
means I need to put some more logic in the mediator which also
feels wrong)?
Comments are currently closed for this discussion. You can start a new one.
2 Posted by krasimir on 30 Nov, 2011 12:19 PM
Hello andreas,
What you have to do is:
addViewListener( SomeEvent.TYPE, dispatch)
I.e. you don't need this forward method. Just pass the dispatch method as a handler.
And have in mind that you should override the clone method in your custom events.
3 Posted by andreas on 01 Dec, 2011 02:32 PM
hi krasimir,
Thank you very much, your suggestion works great!
Thread closed.
andreas closed this discussion on 01 Dec, 2011 02:32 PM.