Backend Application Views

Basically, what I'm trying to do is find the best way to manage all my views. So all my views are closed and created when necessary .. And because of this, I created a separate manager inside my Backbone.Router , which performs all my views as follows.

router.js

  AppRouter.prototype.initialize = function () { ....... var eMgr = _.extend({}, Backbone.Events); var vMgr = new ViewManager(); vMgr.add(new vTopMenu({eMgr: eMgr})); vMgr.add(new vTooltip({eMgr: eMgr})); app_router.on('route:MainMenu', function () { vMgr.close_all_views(function(){ vMgr.add(new vmainMenu({eMgr: eMgr})); vMgr.render_all_views(); }); }); app_router.on('route:showMap', function () { vMgr.close_all_views(function(){ vMgr.add(new vMapMenu()); vMgr.render_all_views(); }); }); ... } 

As you can see, TopMenu views and tooltips are created only once, since I do not expect that it will be necessary to change their contents. And I would also like to avoid spaces while loading views ...

I am not sure if this is a good idea, since all other views are closed and re-initiated as soon as I move from one route to another.

So the question is, are these views created in this way correctly? Or should I always recreate the views when any route starts?

+5
source share
1 answer

Some views may be cached if necessary. The benefits of caching depend on what content you display in the view. When deciding whether to present a view in the cache, several aspects must be considered:

  • Large cache sizes can affect performance, so only those that are often used for caching are selected.
  • Caching is important for those that load additional resources.
  • Remember that unused views can use memory resources.

In addition, for both cached and inactive cases, you should remember:

  • It can also take considerable time to resubmit the view. Those views that are difficult to display can simply be hidden rather than deleted.
  • Submission zombies . The old point of view must be securely closed, events unleashed, etc.
0
source

All Articles