Titanium JIRA Archive
Alloy (ALOY)

[ALOY-432] add destroy() function to all controllers

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2012-12-19T04:12:01.000+0000
Affected Version/sn/a
Fix Version/sAlloy 0.3.4, 2012 Sprint 26
ComponentsRuntime
Labelsnotable
ReporterTony Lukasavage
AssigneeUnknown
Created2012-12-19T03:14:26.000+0000
Updated2018-03-07T22:25:47.000+0000

Description

*IMPORTANT*: Calling destroy() will be critical for preventing memory leaks in alloy code that employs model-view binding. We will be adding a *destroy()* function to all controllers. Under the hood this will be added as:
exports.destroy = function() {
    // auto-generated destroy code
}
In its initial form, the destroy() function will be used only to remove event listeners tied to global and local references to models/collections, which are created when model-view binding is employed. A typical example of using it would be when you close a controller's window if it or any of its UI components used model-view binding.
$.win.on('close', function() {
    $.destroy(); // clean up binding
});
This will prevent any possible memory leaks, specifically when making bindings against a global model (Alloy.Models) or collection (Alloy.Collections).

Comments

  1. Tony Lukasavage 2012-12-19

    All model and collection binding can now be cleaned, and made free of potential memory leaks, by calling destroy() on the controller.

JSON Source