tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/68-how-to-prevent-data-reloadingRobotlegs: Discussion 2013-04-28T10:02:21Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T00:06:54Z2010-03-28T00:07:09ZHow to prevent data reloading..<div><p>Hi all,<br>
I have a command that calls a function in a service that
loads/retreives its data and then creates a vo for that data and
sends the data vo in an event to the mediator.</p>
<p>Once that view is not needed anymore it is hidden and all the
children inside the view is removed.</p>
<p>later when that view is needed again i need to retrieve the data
from the service again and init the view again - how do i do
this??</p>
<p>In puremvc it was easy as the model was a singleton and
internally i could just set a boolean and if the data was already
there it just skiped the load and dispatched the event to the view
but in robotlegs it looks like the mapsingleton of is still
creating new instances as the boolean is always reset the second
time it loads and everything is reloaded - i see in my profiler
that the memory is creeping up each time it is loaded so it must be
loading data again.</p>
<p>My question is how do i go about creating one instance of a
model or service that i can retrieve the data from whenever it is
needed without my memory creeping up or how do i destroy the data
from the memory when the view is hidden (i dont mind reloading the
data but do mind having each reload added to the memory).</p>
<p>Thanks for any help<br>
Monkey</p></div>monkeytag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T00:30:54Z2010-03-28T00:31:25ZHow to prevent data reloading..<div><p>To map a singleton instance of an class, use the following
syntax:<br>
<code>injector.mapSingleton(MyModelClass)</code></p>
<p>You can then ether have your service populate the model or have
a command do it.</p></div>Jason Diastag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T00:37:21Z2010-03-28T00:37:21ZHow to prevent data reloading..<div><p>so have the service save the data to a var in a model then call
the data from the model - how do i inject that model to the
mediator ( in pmvc i used to just retrieve the data buy
proxy.vo.MYVAR )</p></div>monkeytag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T00:50:50Z2010-03-28T00:50:53ZHow to prevent data reloading..<div><p>Yes, the service can call a method on the model and the model
would update/add the VO, then the model dispatches an event that
the mediator picks up.</p>
<p>to inject a model into the mediator;<br>
<code>[Inject] public var model:ModelClass;</code></p>
<p>This should help illustrate the process <a href=
"http://www.robotlegs.org/diagram/">http://www.robotlegs.org/diagram/</a></p></div>Jason Diastag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T01:00:46Z2010-03-28T01:00:46ZHow to prevent data reloading..<div><p>that helps loads - thank you</p></div>monkeytag:robotlegs.tenderapp.com,2009-10-18:Comment/13259292010-03-28T05:32:19Z2010-03-28T05:32:19ZHow to prevent data reloading..<div><p>I'd have to see your code to find out what is breaking down, but
mapSingletonOf does just that... maps a single instance of the
class for injection. I follow the same approach you are used to
with PureMVC in my Robotlegs applications (I've used PureMVC
extensively as well)</p>
<p>If you want to post some code, I'd happily review it.</p>
<p>Cheers</p></div>Joel Hooks