feat(composite): enhance service loading for multiple exports

This commit is contained in:
Samuel Andert
2023-07-25 15:31:35 +02:00
parent c47cf1e338
commit 38ec75d19b
6 changed files with 11 additions and 11 deletions

View File

@ -72,7 +72,6 @@
}
return null;
}
async function getServiceProps(component) {
const loadedServices = [];
if (component.services) {
@ -89,15 +88,15 @@
<div class="grid w-full h-full" style="display: grid; {componentsData.layout || ''}">
{#each componentsData.children as component (component.id)}
{#await Promise.all( [getComponent(component.componentName), getServiceProps(component)] ) then [Component, loadedServices]}
{#await Promise.all( [getComponent(component.componentName), getServiceProps(component)] ) then [Component, serviceProps]}
{#if Component}
<div class="w-full h-full overflow-hidden {component.slot}">
<svelte:component
this={Component}
id={component.id}
{...component.props}
{...loadedServices.reduce((acc, currFn, idx) => {
acc[component.services[idx]] = currFn;
{...serviceProps.reduce((acc, currServiceModule, idx) => {
acc[component.services[idx]] = currServiceModule;
return acc;
}, {})}
/>