Mediator doesn't work when dispatching existing event
Hi
MyEvent is mapped to a command.
MyEvent is dispatched when the user clicked on a button.
So the following is my mediator:
public class MyViewMediator extends Mediator
{
[Inject]
public var view:MyView;
override public function onRegister():void
{
eventMap.mapListener(view, MyEvent.CALCULATE, handleCalculate);
}
private function handleCalculate(event:MyEvent):void
{
// this will not work by dispatching the existing event
// dispatch(event);
// this is working!
dispatch(new MyEvent(MyEvent.CALCULATE));
}
}
I'm wondering why it doesn't work if we dispatching the existing event as commented in the code?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Hez on 25 Jun, 2010 06:52 AM
OK, the problem is resolved by adding the following clone() in MyEvent.
So I think it is a must for Robotlegs application to provide a clone() in every custom event?
Support Staff 2 Posted by Joel Hooks on 25 Jun, 2010 07:17 AM
It is best practice with ANY custom events, irrespective of framework, to override the clone() method. Events cannot be redispatched or bubbled without doing so.
Joel Hooks closed this discussion on 25 Jun, 2010 07:17 AM.