[Telemetry] Unsubscribe on composition change

WTD-1329.
This commit is contained in:
Victor Woeltjen 2015-06-24 12:27:20 -07:00
parent 7a531493d8
commit f98344b5f6

View File

@ -154,6 +154,14 @@ define(
return objects;
}
function unsubscribeAll() {
return unsubscribePromise.then(function (unsubscribes) {
return $q.all(unsubscribes.map(function (unsubscribe) {
return unsubscribe();
}));
});
}
function initialize() {
// Get a reference to relevant objects (those with telemetry
// capabilities) and subscribe to their telemetry updates.
@ -176,7 +184,7 @@ define(
function modelChange(model) {
if (!idsMatch((model || {}).composition || [])) {
// Reinitialize if composition has changed
initialize();
unsubscribeAll().then(initialize);
}
}
@ -201,11 +209,7 @@ define(
if (unlistenToMutation) {
unlistenToMutation();
}
return unsubscribePromise.then(function (unsubscribes) {
return $q.all(unsubscribes.map(function (unsubscribe) {
return unsubscribe();
}));
});
return unsubscribeAll();
},
/**
* Get the most recent domain value that has been observed