Creates a store holding component values which can be accessed synchronously.
This is meant as an alternative to the async value access via await cmp.getValue() for situations where the async
access is especially cumbersome.
E.g.:
constamount = awaitAmount.getValue(); // vs. constamount = cmpValues.Amount;
!!! Note !!!
This shall not be used as the default way of accessing component values. Using this extensively can have negative impact on the performance of your configurator.
Avoid using this with too many components or components that hold very large values which change frequently.
Returns
An object holding the current value of each of the given cmps. The keys of the properties in the returned object are the same as in the given cmps.
Example
// Create the store once and export for later use: import { Amount, ItemPrice } from'./typings/cfgr-defs.generated'; exportconstcmpValues = awaitCmpUtils.createSyncCmpValuesStore({ Amount, ItemPrice });
// Later in the code, access the values synchronously like this: constamount = cmpValues.Amount; constitemPrice = cmpValues.ItemPrice; // or: const { Amount: amount, ItemPrice: itemPrice } = cmpValues;
!!! Important !!!
Once the values of the returned store have been extracted, they will not update anymore. -> Only extract the values in sync contexts.
E.g.:
import { cmpValues } from'./path/to/store';
constamount = cmpValues.Amount; // Current value of Amount is 10
button.onClick(() => { // The value of Amount changed to 20 in the meantime console.log(amount); // 🔥 Stale value 10 console.log(cmpValues.Amount); // ✅ Latest value 20 });
Creates a store holding component values which can be accessed synchronously.
This is meant as an alternative to the async value access via
await cmp.getValue()for situations where the async access is especially cumbersome.E.g.:
!!! Note !!!
This shall not be used as the default way of accessing component values.
Using this extensively can have negative impact on the performance of your configurator.
Avoid using this with too many components or components that hold very large values which change frequently.
Returns
An object holding the current value of each of the given
cmps.The keys of the properties in the returned object are the same as in the given
cmps.Example
!!! Important !!!
Once the values of the returned store have been extracted, they will not update anymore.
-> Only extract the values in sync contexts.
E.g.: