implement destroy util function in js utility registry
This commit is contained in:
parent
f4ed279a15
commit
04d0f19d9c
@ -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
|
||||
|
||||
Reference in New Issue
Block a user