BillyMedia
BillyMedia

Reputation: 1354

Sencha touch 2 - Memory management - destroying tab panels

I want to ensure my app is handling memory correctly, i have it destroying panels on the 'erased' event, but when i do this to tab panels, it obviously removes them from the tabbar.

What strategy is best for handling memory and when tab panels are out of view?

Upvotes: 1

Views: 898

Answers (1)

Alexander Rolek
Alexander Rolek

Reputation: 973

This can actually be done, and it's a great technique but it's a bit difficult to implement. First off you need to not use the tabpanel. You need to create your own version of the tabpanel. The strategy is this:

  • Create a container with layout: 'card'. This container will hold your panels.
  • Dock a toolbar to the bottom of this container and fill the items array with different tabs
  • In your controller add 'control' properties to your config object for each of the tabs in the toolbar and listen for the tab 'tap' event;
  • On tab 'tap' you will render each view to your container.
  • Add an 'activeitemchange' event listener to your container and destroy the oldCard.

I put together some boilerplate awhile back when Sencha Touch 2 was in pre release. The concepts are still applicable, though some of the code needs to be upgraded. Take a look here:

https://github.com/ARolek/Sencha-Touch-2.0-MVC-Boilerplate

This is not an easy concept, so let me know what needs clarification.

Hope this helps.

Upvotes: 1

Related Questions