updated the reference key for data and store to store mapping to @data: and @storeID: in composite.

This commit is contained in:
Samuel Andert
2023-07-27 14:28:40 +02:00
parent 1ce7b80c9b
commit b546a22302
7 changed files with 33 additions and 24 deletions

View File

@ -93,10 +93,13 @@
if (component.map) {
const localStore = getCompositeStore(component.id);
for (const [localKey, external] of Object.entries(component.map)) {
const [externalID, externalKey] = external.split('.').map((item) => item.trim());
for (const [localKey, mapping] of Object.entries(component.map)) {
const isDataMapping = mapping.startsWith('@data:');
const isStoreMapping = mapping.startsWith('@');
if (isDataMapping) {
const externalKey = mapping.replace('@data:', '').trim();
if (externalID === 'data') {
const unsubscribe = dataStore.subscribe((store) => {
if (externalKey in store) {
if (store[externalKey] && typeof store[externalKey].subscribe === 'function') {
@ -114,7 +117,12 @@
});
unsubscribers.push(unsubscribe);
} else {
} else if (isStoreMapping) {
const [externalID, externalKey] = mapping
.replace('@', '')
.split(':')
.map((item) => item.trim());
const externalStore = getCompositeStore(externalID);
if (externalStore) {
const unsubscribe = externalStore.subscribe((externalState) => {