Opened 9 years ago

Closed 7 years ago

#16974 closed enhancement (patchwelcome)

[dojox/app] Add support to unload/destroy a view

Reported by: Paul Christopher Owned by: Ed Chatelain
Priority: undecided Milestone: 1.13
Component: DojoX App Version: 1.9.0b2
Keywords: Cc:
Blocked By: Blocking:


As already discussed on the mailing list It would be nice if there were means to unload/ destroy a view from the DOM so as to keep memory consumption to a minimum.

Maybe there need to be functions which allow the programmer to destory views manually (e.g. in afterDeactivate by calling view.unload). Or there needs to be a switch in the appconfig.json file, which tells the main application controller to destroy a view (or only certain views that are marked for that?) once a view transition is performed to another view/ a view gets hidden.

Change History (4)

comment:1 Changed 9 years ago by Ed Chatelain

A custom controller "UnloadViewController?" was added to the dojox/app/tests/layoutApp2 test to show how to unload/destroy a view. The name of the controller is: dojox/app/tests/layoutApp2/controllers/UnloadViewController

You can see how to unload a view by looking at the code in views/date.js.

comment:2 Changed 9 years ago by Paul Christopher

Thanky for adding this! I will have a look at the exmaple. By the way: In a lot of view controllers, handles are pushed into an array. I wonder whether this is still necessary: Can't you simply use this.own(handle)?

comment:3 Changed 9 years ago by Paul Christopher

Removing the view works nicely. However I am wondering, if there is also a way to completely unload the controller? In a multilayer build scenario, I have tried to call require.undef in the view's destroy method - without much success. The view is correctly unloaded from the DOM, but when navigating back to the unloaded scene, I cannot see a second call for the controller file in the console.

Or do you think, it is not a good idea to unload the controller itself? My idea was, to totally get rid off a scene not only in the DOM but also in the browsers memory, i.e. to unload the compressed controller file, too.

comment:4 Changed 7 years ago by dylan

Milestone: tbd1.12
Resolution: patchwelcome
Status: newclosed

Given the lack of attention to this ticket, we would accept a pull request. Closing as patchwelcome.

Note: See TracTickets for help on using tickets.