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

@ -1,8 +1,9 @@
<script>
import { AppBar } from '@skeletonlabs/skeleton';
export let store;
</script>
<AppBar>
<h1 class="h4">Nova</h1>
<!-- <h1 class="h4">{$store.dapp.name}</h1> -->
<!-- <svelte:fragment slot="trail">(actions)</svelte:fragment> -->
</AppBar>

View File

@ -3,7 +3,6 @@
export let store;
let isStoreLoaded = false;
$: console.log('store: ' + JSON.stringify($store));
$: if (services && services.helloEarthAlert) {
// services.helloEarthAlert.alertMe();

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) => {

View File

@ -2,7 +2,7 @@
import Composite from '$lib/core/Composite.svelte';
let composite = {
id: 'google',
id: 'login',
component: 'GoogleAuth',
services: ['setupLit']
};

View File

@ -2,7 +2,7 @@
import Composite from '$lib/core/Composite.svelte';
let composite = {
id: 'composite',
id: 'hello',
layout: {
areas: `
"main"
@ -16,10 +16,8 @@
component: 'HelloEarth',
slot: 'main',
map: {
pkpWallet: 'w.pkpWallet',
rpcURL: 'w.rpcURL',
messages: 'data.queryMessages',
todos: 'data.queryTodos'
pkpWallet: '@wallet.pkpWallet',
todos: '@data:queryTodos'
},
services: ['helloEarthAlert']
},

View File

@ -1,11 +1,8 @@
<script>
import Composite from '$lib/core/Composite.svelte';
import { dataStore } from '$lib/core/dataLoader';
$: console.log('Data Store contents:', $dataStore);
let composite = {
id: 'composite',
id: 'messages',
layout: {
areas: `
"top top"
@ -21,7 +18,7 @@
id: 'me',
component: 'Messages',
slot: 'main',
map: { messages: 'data.queryMessages' }
map: { messages: '@data:queryMessages' }
},
{
id: 'terminal',

View File

@ -2,7 +2,13 @@
import Composite from '$lib/core/Composite.svelte';
let composite = {
id: 'composite',
id: 'wallet',
store: {
pkpWallet: '',
rpcURL: 'https://rpc.gnosischain.com/',
pkpPubKey:
'046da3ba67065fd1e2726242ca01cd4601524893f4aa4b0042578fa6cbec28fa8c9a28eb9f7893932fc09717edc9e1db57e157a21eed346247c1db5a722a01f571'
},
layout: {
areas: `
"top"
@ -18,14 +24,14 @@
slot: 'top'
},
{
id: 'wallet',
id: 'xyz',
component: 'Wallet',
slot: 'main',
store: {
pkpWallet: '',
rpcURL: 'https://rpc.gnosischain.com/',
pkpPubKey:
'046da3ba67065fd1e2726242ca01cd4601524893f4aa4b0042578fa6cbec28fa8c9a28eb9f7893932fc09717edc9e1db57e157a21eed346247c1db5a722a01f571'
map: {
rpcURL: '@wallet:rpcURL',
pkpPubKey: '@wallet:pkpPubKey',
pkpWallet: '@wallet:pkpWallet',
todos: '@data:queryTodos'
}
},
{