So i have different states(with different controllers), each state fetching data from api. But if user leave state before request is resolved, then handler is called when he is not in this state. That's not intended. Moreover some of handlers have $intervals fetching data (after resolving 1st request) -> so the data keep fetching and fetching while user moved away hours ago. First thing that came to my mind:
let isDestroyed = false;
$http.get('/someurl').then(response => {
if (isDestroyed) return;
processResponse();
});
$scope.$on('$destroy',() => {
isDestroyed = true;
});
What else can i do?