implement destroy util function in js utility registry

This commit is contained in:
Felix Hamann 2019-04-10 22:51:03 +02:00
parent f4ed279a15
commit 04d0f19d9c

View File

@ -106,8 +106,25 @@
}
function _destroyUtilInstances(name) {
console.log('TODO: destroy util instances', { name });
// call destroy on each activeUtilInstance that matches the name
activeUtilInstances
.map(function(util, index) {
return {
util: util,
index: index,
};
}).filter(function(activeUtil) {
// find utils instances to destroy
return activeUtil.util.name === name;
}).forEach(function(activeUtil) {
// destroy util instance
activeUtil.util.destroy();
delete activeUtilInstances[activeUtil.index];
});
// get rid of now empty array slots
activeUtilInstances = activeUtilInstances.filter(function(util) {
return !!util;
})
}
// public API