This document - Modifying Components Outside the Framework Lifecycle - says the following:
You don't need a cmp.isValid() check within this setTimeout() call as the cmp.set() call doesn't do anything when the component is invalid.
window.setTimeout(
$A.getCallback(function() {
cmp.set("v.visible", true);
}), 5000
);
Whereas Trailhead - Secure Your Lightning JavaScript Code (Asynchronous JavaScript) - states quite the opposite:
If you want your function to access data in a Lightning component, you can always reach the framework with the $A.getCallback() closure. Use cmp.isValid() inside the closure to check that your component still exists.
waitAndChange: function(cmp,evt,hlp){
setTimeout(function(){
$A.getCallback(function(){ // access the framework in a closure
if(cmp.isValid()){ // does the component exist in this context?
cmp.set("v.resultAttr","new value");
}
});
}, 2000);
}
With that being said, when and why do I need to perform `cmp.isValid()' check?