I just run into an edge case:
set(values={}) {
let me = this;
// instead of using:
// me[configSymbol] = values;
// we keep the Object instance (defined via Object.defineProperties() => non enumerable)
Object.keys(me[configSymbol]).forEach(key => {
delete me[configSymbol][key];
});
Object.assign(me[configSymbol], values);
me.processConfigs(true);
}
The logic of set() is intended to re-use the configSymbol. However, in case we are calling set() before the initial processing is done (e.g. inside an afterSetConfig() method), the current logic does delete entries which still need to get processed.
Instead, we should check if there are entries left inside the symbol and if so, process them first.
processConfig() can get used with a forceAssign param. We need to ensure that the processing continues with the same value, so we need to store the current mode inside a class property. E.g. if a config without an underscore does get assigned inside an afterSet() method, we do not want to override the new value with the initial value.
This also affects calling set()inside an afterSet method which got triggered by calling set() itself. It feels best to finish the previous set call(s) first, before pushing more values into the chain.
I just run into an edge case:
set(values={}) { let me = this; // instead of using: // me[configSymbol] = values; // we keep the Object instance (defined via Object.defineProperties() => non enumerable) Object.keys(me[configSymbol]).forEach(key => { delete me[configSymbol][key]; }); Object.assign(me[configSymbol], values); me.processConfigs(true); }The logic of
set()is intended to re-use the configSymbol. However, in case we are callingset()before the initial processing is done (e.g. inside anafterSetConfig()method), the current logic does delete entries which still need to get processed.Instead, we should check if there are entries left inside the symbol and if so, process them first.
processConfig()can get used with aforceAssignparam. We need to ensure that the processing continues with the same value, so we need to store the current mode inside a class property. E.g. if a config without an underscore does get assigned inside an afterSet() method, we do not want to override the new value with the initial value.This also affects calling
set()inside an afterSet method which got triggered by callingset()itself. It feels best to finish the previous set call(s) first, before pushing more values into the chain.