tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/621-lazystack-gethub-example-and-multiple-contextsRobotlegs: Discussion 2018-10-18T16:35:30Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/89582062011-07-29T19:09:27Z2011-07-29T19:09:27ZLazyStack gethub Example and multiple contexts<div><p>Ok, I think I found the answer my own question here looking at
the best practices again. I found this</p>
<p><em>' Framework actors live within a context and communicate
with one another within the scope of that context. It is possible
to have several contexts within a single application. This is
useful for applications that want to load external modules. While
the actors within a context can only communicate within the scope
of their context, it is possible for contexts to communicate with
one another in a modular application."</em></p></div>visniktag:robotlegs.tenderapp.com,2009-10-18:Comment/89582062011-07-29T20:24:24Z2011-07-29T20:24:24ZLazyStack gethub Example and multiple contexts<div><p>OK, maybe i closed this a little premature, as I still have
question regarding the multiple context, and scope. I decided to
mess around with multiple context as a result of looking at the
LazyStack example, and realized... I am going to have to have a
model for each context. Here is what I am doing that lead me to
that conclusion.</p>
<p>I have my MainApp.mxml, it has has a MainScreenContainer.mxml
component within it. I was thinking about dynamically loading some
screens (that will have there own states) in and out of this
MainScreenContainer.</p>
<p>So in ScreenOne.mxml I have the following:</p>
<p>`private var context:NewGameContext;</p>
<pre>
<code>private function onPreInitialization():void
{
context = new ScreenOneContext(this);
}'</code>
</pre>
<p>and will pretty much do the same for all other screens.</p>
<p>I got thinking, I will need a model for each screen, as each
model will only be scoped for it's context.</p>
<p>Am I incorrect in thinking this?</p></div>visniktag:robotlegs.tenderapp.com,2009-10-18:Comment/89582062011-07-30T11:29:34Z2011-07-30T11:30:25ZLazyStack gethub Example and multiple contexts<div><p>Hi visnik,</p>
<p>In the <a href=
"https://github.com/darscan/robotlegs-demos-Bundle/tree/master/LazyStack/src">
example you mentioned</a> @Shaun shows that you can create multiple
contexts of the same type in one application.</p>
<p>I'm wondering if you're going to load external SWFs with their
contexts or just to add views dynamically. If you're going to load
external SWFs I'd rather recommend you <a href=
"https://github.com/joelhooks/robotlegs-utilities-Modular">modular
contexts</a> by @Joel Hooks - <a href=
"http://joelhooks.com/2010/05/02/modular-robotlegs/">Here</a> you
can find a description of that utility. If your're just going to
add views dynamically I think you don't need separate contexts for
that, but it doesn't mean it won't work. If they'll need to
comunicate between each other, and inject common objects, use one
context for all the application or use Modular utility by
@Joel.</p>
<p>If it doesn't satisfy you, give me more details :)</p>
<p>Thanks,<br>
Mike</p></div>Michal Wroblewskitag:robotlegs.tenderapp.com,2009-10-18:Comment/89582062011-07-30T13:20:48Z2011-07-30T13:20:48ZLazyStack gethub Example and multiple contexts<div><p>Hi visnik,</p>
<p>I hope that example wasn't too misleading - it is very old and
not very clear. It's purpose was simply to demonstrate that
multiple identical contexts can live side-by-side in an application
without interfering with each other. It does not represent a
typical use-case by any means.</p>
<p>Most applications will have just a single context. In your case,
I would have one context and separate mediators for each
dynamically added screen.</p>
<p>Hope that helps</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/89582062011-08-02T15:50:31Z2011-08-02T15:50:31ZLazyStack gethub Example and multiple contexts<div><p>Thanks guys, I appreciate you help. @Michal I am currently
diving into the Modular context by Joel Hooks, trying to learn as
much about RL as I can. Thanks, your replies were very helpful.</p></div>visnik