Robotlegs - second dispatch does not work with addViewListener
I have a mediator created in Robotlegs, and its related view would dispatch two different kinds of events. When the mediator captures the event, it would just simply dispatch the event. The problem I ran into was that the first event is re-dispatched flawlessly, but the 2nd event was not dispatched.
However, if I manually assign a different handler to the 2nd event, the event is properly captured.
Below is the relevant code:
public class MyMediator extends Mediator
{
[Inject]
public var view:MyView;
public override function onRegister():void
{
super.onRegister();
addViewListener( SomeEventTypeA.COOL_EVENT, dispatch, SomeEventTypeA ); // This event is dispatched correctly
addViewListener( SomeEventTypeB.STUCK, dispatch, SomeEventTypeB ); // This one is not correctly dispatched
//A twist, if I uncomment the following code, the event is captured by its handler
//addViewListener( SomeEventTypeB.STUCK, view_stuck, SomeEventTypeB );
}
private function view_stuck( event:SomeEventTypeB ):void
{
//ah ha, this is called correctly if the above relevant line is uncommented
}
}
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
Support Staff 1 Posted by Ondina D.F. on 23 Dec, 2012 12:24 PM
Hey tangent,
Since it works within the view_stuck() handler, it’s most likely you forgot to override clone() in your SomeEventTypeB.
See: http://knowledge.robotlegs.org/kb/application-architecture/why-does...
On a side note, you don’t need to call super.onRegister(); if you have this:
override public function onRegister():void
{
}
Let me know whether overriding clone() solved your issue or not.
Ondina
2 Posted by tangent on 23 Dec, 2012 01:24 PM
Ondina, you are quite correct, I didn't have proper clone method for the particular event. After adding proper clone method, it works as expected!
Support Staff 3 Posted by Ondina D.F. on 24 Dec, 2012 03:42 PM
Hi tangent,
I’m glad you are back on track.
Ondina
Ondina D.F. closed this discussion on 24 Dec, 2012 03:42 PM.