fix(inspectedApp): handle refresh better

master
Brian Ford 9 years ago
parent 287074b73e
commit fce0052322

@ -80,11 +80,17 @@ function inspectedAppService($rootScope, $q) {
if (hint.event === 'scope:new') {
addNewScope(hint);
} else if (hint.id && scopes[hint.id]) {
if (hint.event === 'model:change') {
scopes[hint.id].models[hint.path] = (typeof hint.value === 'undefined') ?
var scope = scopes[hint.id];
if (hint.event === 'scope:destroy') {
if (scope.parent) {
scope.parent.children.splice(scope.parent.children.indexOf(child), 1);
}
delete scopes[hint.id];
} else if (hint.event === 'model:change') {
scope.models[hint.path] = (typeof hint.value === 'undefined') ?
undefined : JSON.parse(hint.value);
} else if (hint.event === 'scope:link') {
scopes[hint.id].descriptor = hint.descriptor;
scope.descriptor = hint.descriptor;
}
}
$rootScope.$broadcast(hint.event, hint);
@ -92,6 +98,7 @@ function inspectedAppService($rootScope, $q) {
}
function onRefreshMessage() {
clear(scopes);
hints.length = 0;
}
@ -106,4 +113,10 @@ function inspectedAppService($rootScope, $q) {
}
}
function clear (obj) {
Object.keys(obj).forEach(function (key) {
delete obj[key];
});
}
}