LearnNewsExamplesServices
Frontmatter
id2201
titlecore.Base: set() => add support for set calls while processConfig() is running
stateClosed
labels
enhancement
assigneestobiu
createdAtMay 29, 2021, 11:24 AM
updatedAtMay 29, 2021, 11:31 AM
githubUrlhttps://github.com/neomjs/neo/issues/2201
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 29, 2021, 11:31 AM

core.Base: set() => add support for set calls while processConfig() is running

Closed v8.1.0 enhancement
tobiu
tobiu commented on May 29, 2021, 11:24 AM

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.

tobiu added the enhancement label on May 29, 2021, 11:24 AM
tobiu assigned to @tobiu on May 29, 2021, 11:24 AM
tobiu referenced in commit caa4d91 - "core.Base: set() => add support for set calls while processConfig() is running #2201" on May 29, 2021, 11:31 AM
tobiu closed this issue on May 29, 2021, 11:31 AM
tobiu cross-referenced by #2207 on May 29, 2021, 3:58 PM