How to set the config value in an updater function


Is there a way to set a config value in its own updater function?

Example: (silly and contrived)

foo: { value: 'bar', update: function (newValue, oldValue) { combinedValue = 'baz' + oldValue + newValue; // make value of 'foo' == combinedValue } }



I figured it out: use transform instead of update

1 Like


Yep! You figured it out. transform is used to change the value of an individual config (make sure to return the value at the end of the function), and update uses the already-transformed value of the config to do things like update other config values based on this one, interact with DOM elements if the component is rendered, or trigger methods to occur whenever the parameter is changed.

So you’d want something like

foo: {
      value: 'bar',
      transform: function (newValue, oldValue) {
            combinedValue = 'baz' + oldValue + newValue;
            return combinedValue;