[question] What's the proper way to clean up nodes?
trusktr opened this issue · comments
Can you give a short example of the proper way to make sure nodes are cleaned up when removed from a scene graph?
@trusktr just leaving this here for the next victim of this problem...
var Dismount = function(node) {
var aNodes = [];
if ( !(node instanceof famous.core.Node) )
throw "node not a Famous#Node";
var f = function(current) {
aNodes.push(current);
var aChildren = current.getChildren();
for ( var i in aChildren )
f(aChildren[i]);
};
f(node);
while ( aNodes.length ) {
var x = aNodes.pop();
if ( x.isMounted())
x.dismount();
}
}
Haven't had any problems with the above recently.