tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/12457-re-disptaching-an-event-to-the-shared-eventdispatcherRobotlegs: Discussion 2014-12-05T11:51:21Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/349141672014-10-13T12:13:21Z2014-10-13T12:13:21ZRe-disptaching an event to the shared eventDispatcher<div><p>What you've discovered, is a functionality that has been there
since the beginnings of rl :)<br>
Having the Mediator's dispatch() method as the event handler is a
very common usage.</p>
<blockquote>
<p>But I am wondering, will using "dispatch" as my event handler
callback cause any bad side effects?</p>
</blockquote>
<p>The dispatch(event); in your enterFrameHandler() is Mediator's
dispatch():</p>
<p><a href=
"https://github.com/robotlegs/robotlegs-framework/blob/master/src/robotlegs/bender/bundles/mvcs/Mediator.as#L94">
https://github.com/robotlegs/robotlegs-framework/blob/master/src/ro...</a></p>
<p>There are no disadvantages per se, when re-dispatching an event
to rl's event bus. What kind of side effects were you expecting to
come from this?</p>
<p>Perhaps you are referring to issues related to listening
directly to a view (garbage collection issues/destroying mediators)
or its subcomponents (for example non-bubbling events)? Or, to
issues caused by dispatching custom events that don't override
Event's clone() method()? Or, by forgetting to set the eventClass
parameter ( the third optional parameter in
addViewListener/addContextListener), which is meant to create a
type safe mapping?<br>
Or, when you map a command to something like a MouseEvent.CLICK,
that can be re-dispatched from several mediators? Or, the fact that
if you don't dispatch custom events from views, you'd have to
change the addViewListener in your mediators, if a MouseEvent is
replaced by a Touch event in your views (for example if you build a
desktop and a mobile version for your app) ?</p></div>Ondina D.F.