tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/11677-manual-teardownRobotlegs: Discussion 2018-10-18T16:35:56Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/342511122014-08-25T17:30:50Z2014-08-25T17:30:50ZManual TearDown <div><p>Hey Dan,</p>
<p>There has to be some sort of communication between the parent
app and yours.<br>
How does the parent application use your module?<br>
Is there a contextView added to the stage of the parent
application?<br>
If not, how do you know when to create a robotlegs context? Through
an API? Is your 'class factory' creating the context and your
views?<br>
Are you keeping a dictionary of views in your class factory?</p>
<p>Oh, wait! I'm having a déjà vu moment :) Your use
case sounds familiar to me. Isn't it the same as in this thread ?
:<br>
<a href=
"http://knowledge.robotlegs.org/discussions/questions/7928-using-robotlegs-in-just-one-module">
http://knowledge.robotlegs.org/discussions/questions/7928-using-rob...</a><br>
I'll probably have to read through the entire discussion again, to
fully understand the scenario.</p>
<p>Currently, the classes under the mediatorMap package aren't
exposing an API for getting a list of mapped mediators, so,
personally, I don't know how you could use them for your
purpose.</p>
<p>You could, however, create your own dictionary (or a collection
of your choice), like the one inside of MediatorFactory. Each time
a mediator is created (initialize()), you also add it to the
dictionary, for example via an
event->command->model->dictionary.<br>
Each time a mediator gets destroyed, you can dispatch an event from
within its destroy() method to let another command access your
model->dictionary.<br>
The model deletes the mediator from the dictionary, and when the
dictionary is empty it dispatches an event for which your context
has added a listener, so it can destroy itself:
context.destroy().<br>
You can simplify the workflow as you wish or need, if you don't
like the long event->command->model path.</p>
<p>Does that help?</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/342511122014-08-25T17:46:30Z2014-08-25T17:46:30ZManual TearDown <div><p>Yup---thats my thread ;-)</p>
<p>Thanks for the example. This is the direction I was intending to
go. The parent application has several entry points into my
application (right click context menu, click through to top level
view, or a user's bookmark to a specific view of about 10), I've
got the entry points covered and the context view is presently the
top level application.</p>
<p>So for tear down, I'll do what you've suggested and when the
view count falls to zero, I'll wait a minute or so and then destroy
the context.</p></div>dan