tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/20-robotlegs-2-use-casesRobotlegs: Discussion 2012-07-16T08:27:16Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-27T15:12:24Z2012-04-27T15:13:32ZRobotlegs 2 use cases<div><p>Hi Quentin,</p>
<ol>
<li>
<p>Now you can call <code>mediatorMap.handleView(contextView,
RL2FirstApp);</code> after it's mapped
<code>mediatorMap.mapView(RL2FirstApp).toMediator(RL2FirstAppMediator);</code>
It'll do the same as <code>createMediator(contextView)</code> in
RL1.</p>
</li>
<li>
<p>Currently it's using ManagedObject (which extends StateMachine)
for Context lifecycle and you can achieve it by adding
<code>POST_INITIALIZE</code> state handler
<code>context.addStateHandler(ManagedObject.POST_INITIALIZE,
contextInitialized)</code> and remember to have
<code>context:IContext</code> injected to the config class. But as
for the latest commits by @Stray there will be Lifecycle class
which will be used instead of ManagedObject (I suppose) and a
<a href=
"https://github.com/robotlegs/robotlegs-framework/tree/version2/src/robotlegs/bender/core/lifecycle">
here you can find very well documented info about it</a></p>
</li>
</ol></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-27T15:21:00Z2012-04-27T15:21:16ZRobotlegs 2 use cases<div><p>Hey Quentin,</p>
<p>I'm not sure why the main view isn't being automatically
mediated - but there's still work to be done in that area, so
hopefully we'll sort that out soon.</p>
<p>Regard point 2: I'd avoid dealing directly with
ManagedObject/Lifecycle unless you are writing extensions. For
normal app startup you can just include a simple config class as
the last configuration in your setup and dispatch an event from
that. There will be a better mechanism for this before the
beta.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-27T15:28:42Z2012-04-27T15:28:42ZRobotlegs 2 use cases<div><p>Again, you (both) rock!<br>
Great answers, work perfectly.</p>
<p>I know (I'm sure!) things will evolve for the best, just wanted
to start playing with current version on GitHub.</p></div>Quentintag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-27T15:34:08Z2012-04-27T15:34:08ZRobotlegs 2 use cases<div><p>Coolness, all feedback is useful :)</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-27T21:05:08Z2012-04-27T21:05:08ZRobotlegs 2 use cases<div><p>I haven't specifically tried mediating the contextView, so I
don't know the<br>
answer to your first item.</p>
<p>My wild random guess is that maybe it's like in RL1 where in
most cases you<br>
had to not only map your contextView, but also call
createMediator() on it<br>
(since it already exists and is on the display list at the time
Context.startup() was running. But I'm probably wrong.</p>
<p>For the second one, you can just map your own custom startup
event to your<br>
startup command(s), then dispatch that event at the end of your<br>
configuration sequence, e.g.:</p>
<p>// in MyConfig startup() or configure() or whatever you call it
// Requires injections for: // - commandMap:IEventCommandMap // -
eventDispatcher:IEventDispatcher</p>
<p>commandMap.map(StartupEvent.STARTUP, StartupEvent,<br>
true).toCommand(StartDoingThings);</p>
<p>// ...</p>
<p>eventDispatcher.dispatchEvent(new
StartupEvent(StartupEvent.STARTUP));</p>
<p>Paul</p></div>Paul Robertsontag:robotlegs.tenderapp.com,2009-10-18:Comment/156081382012-04-29T11:41:57Z2012-04-29T11:41:57ZRobotlegs 2 use cases<div><p>Thanks for your suggestion Paul.</p>
<p>I thought about doing so, and it makes perfect sense. Only thing
is, I was wondering if such an event already existed, so I wouldn't
have to write my own (like I used to do with RL1)!</p>
<p>Seems like there isn't one, but that's perfectly fine!</p></div>Quentin