From b9e22e1ea40233e53c9ad2beabd2c1aad9c1acf5 Mon Sep 17 00:00:00 2001 From: Samuel Andert Date: Mon, 7 Aug 2023 12:33:37 +0200 Subject: [PATCH] further improving the component interface. --- src/lib/components/refactor/ComposerAlice.svelte | 2 +- src/lib/components/refactor/ComposerBob.svelte | 4 ++-- src/lib/components/refactor/ComposerForm.svelte | 4 ++-- src/lib/core/refactor/Composer.svelte | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/components/refactor/ComposerAlice.svelte b/src/lib/components/refactor/ComposerAlice.svelte index 4574c83..6cc28fb 100644 --- a/src/lib/components/refactor/ComposerAlice.svelte +++ b/src/lib/components/refactor/ComposerAlice.svelte @@ -11,7 +11,7 @@ $: { if ($composerBob.state) { - $me.do.machine.send($composerBob.state); + $me.do.state.send($composerBob.state); } } // Call testAlert diff --git a/src/lib/components/refactor/ComposerBob.svelte b/src/lib/components/refactor/ComposerBob.svelte index cd9e3a6..e2d6174 100644 --- a/src/lib/components/refactor/ComposerBob.svelte +++ b/src/lib/components/refactor/ComposerBob.svelte @@ -2,8 +2,8 @@ export let me; const handleButton = () => { - if ($me.do.machine) { - $me.do.machine.send('TOGGLE'); + if ($me.do.state) { + $me.do.state.send('TOGGLE'); } }; diff --git a/src/lib/components/refactor/ComposerForm.svelte b/src/lib/components/refactor/ComposerForm.svelte index 868e8f5..dda5c9f 100644 --- a/src/lib/components/refactor/ComposerForm.svelte +++ b/src/lib/components/refactor/ComposerForm.svelte @@ -32,9 +32,9 @@ $: { // Send events to the state machine based on the validation status if (!($errors.name || $errors.email || $errors.about || $errors.age || $errors.favoriteFood)) { - $me.do.machine.send('VALIDATE'); + $me.do.state.send('VALIDATE'); } else { - $me.do.machine.send('INVALIDATE'); + $me.do.state.send('INVALIDATE'); } } diff --git a/src/lib/core/refactor/Composer.svelte b/src/lib/core/refactor/Composer.svelte index 37e3c3a..9c8330e 100644 --- a/src/lib/core/refactor/Composer.svelte +++ b/src/lib/core/refactor/Composer.svelte @@ -65,8 +65,9 @@ id: component.id, do: { core: coreServices, - machine: component.machineService || null - } + state: component.machineService || null + }, + data: component.data || {} // Add this line })); if (component.children) {