tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/439-managing-your-views-with-commands-vs-a-mediated-contextviewRobotlegs: Discussion 2013-04-28T10:22:27Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/51444872011-02-05T13:03:24Z2011-02-05T13:03:24ZManaging your views with commands vs. a mediated contextView<div><p>I would always go for some form of the first option, because
that way your application will be more flexible. It would be
bothersome to have to update your ApplicationView and
ApplicationMediator every time you add another view. The nice thing
about Mediators is that they have the possibility to 'decide'
themselves what to do in a certain situation. It also gives them a
nice SRP (Single Responsibility Principle) approach. So the bottom
line: try to avoid 'big' managers as much as possible. Delegate the
event handling to the components in question.</p></div>Abel de Beertag:robotlegs.tenderapp.com,2009-10-18:Comment/51444872011-02-05T15:31:32Z2011-02-05T15:31:32ZManaging your views with commands vs. a mediated contextView<div><p>@Abel</p>
<p>I get what you're saying. I actually stumbled across a cool
library last night while I was looking through GitHub: <a href=
"https://github.com/MrDodson/navigator-as3">https://github.com/MrDodson/navigator-as3</a><br>
Maybe some folks here use it?</p>
<p>However I'm still wondering how you would manage to sequence
your outtro animations if each mediator was handling the process of
removing its view from stage.</p></div>robtag:robotlegs.tenderapp.com,2009-10-18:Comment/51444872011-02-19T23:03:42Z2011-02-19T23:03:42ZManaging your views with commands vs. a mediated contextView<div><p>I tend to do what you were describing with the events. The app
moves through various states (I have a separate module that is just
a state machine really) and various view mediators are set up to
listen for the relevant events to show / hide their view (using the
view api).</p>
<p>If you need to vary the view-transition animations for different
apps then I'd always suggest adding the transition animation by
composition, then you can easily switch it in/out (also saves a lot
of code duplication!)</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/51444872011-03-20T02:48:18Z2011-03-20T02:48:18ZManaging your views with commands vs. a mediated contextView<div><p>So if view A needs to transition out completely before view B
starts to transition out, does view A trigger a command of some
kind to tell view B to start animating out? Furthermore, does view
B trigger a command to inform the state machine that the whole
sequence is complete?</p></div>robtag:robotlegs.tenderapp.com,2009-10-18:Comment/51444872011-03-24T12:13:03Z2011-03-24T12:13:03ZManaging your views with commands vs. a mediated contextView<div><p>When you say "trigger a command" - I would say "dispatch an
event".</p>
<p>But - generally I would say that both respond to an application
event.</p>
<p>So - for example "AppStatusChangeEvent.OPEN_LIBRARY" causes my
normal view to transition out, and my library view to transition
in. If required, the library view can delay their response.</p></div>Stray