Convenience Method for Re-dispatching View Events in a Mediator?
This may be more suited for the Google Groups list; but I don't want to add unnecessary noise to that board!
I seems to find writing code to redispatch an event from one of my view components back into the Framework in my Mediators. The code ends up looking like this:
override public function onRegister() : void {
eventMap.mapListener(myView, ViewEvent.FOO, redispatchEvent, ViewEvent);
}
private function redispatchEvent(event : Event) : void {
dispatch(event.clone());
}
Is there an opportunity for adding an syntactic sugar to make re-dispatching these View events back into the framework easier, or am I missing something here?
Thanks
jonny.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Shaun Smith on 08 Mar, 2010 12:55 PM
Have you tried this:
Support Staff 3 Posted by Till Schneidereit on 08 Mar, 2010 12:57 PM
That functionality is already included - it's just that it's too
obvious to see. I know that it took a hint in the support area for me
to see it, at least.
What you're doing in your redispatchEvent method is exactly what
dispatch already does for you: It (re-)dispatches an event to the
Robotlegs event bus. Thus, you can just use dispatch as the event
handler and be done with it:
In Robotlegs 1.1, that will be simplified to
4 Posted by Jonny Reeves on 08 Mar, 2010 12:58 PM
Well don't I feel foolish! I've just updated the Best Practices document to make mention of this as that's the first place I looked for the answer.
Thanks guys :)