How to prevent data reloading..

monkey's Avatar


28 Mar, 2010 12:06 AM

Hi all,
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.

Once that view is not needed anymore it is hidden and all the children inside the view is removed.

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??

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.

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).

Thanks for any help

  1. 1 Posted by Jason Dias on 28 Mar, 2010 12:30 AM

    Jason Dias's Avatar

    To map a singleton instance of an class, use the following syntax:

    You can then ether have your service populate the model or have a command do it.

  2. 2 Posted by monkey on 28 Mar, 2010 12:37 AM

    monkey's Avatar

    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 )

  3. 3 Posted by Jason Dias on 28 Mar, 2010 12:50 AM

    Jason Dias's Avatar

    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.

    to inject a model into the mediator;
    [Inject] public var model:ModelClass;

    This should help illustrate the process

  4. 4 Posted by monkey on 28 Mar, 2010 01:00 AM

    monkey's Avatar

    that helps loads - thank you

  5. Support Staff 5 Posted by Joel Hooks on 28 Mar, 2010 05:32 AM

    Joel Hooks's Avatar

    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)

    If you want to post some code, I'd happily review it.


  6. Stray closed this discussion on 16 Feb, 2011 09:04 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac