refactoring next part
This commit is contained in:
@ -43,12 +43,22 @@
|
||||
});
|
||||
}
|
||||
if (composer?.machine) {
|
||||
const machine = Machine({ ...composer.machine, id: composer.id });
|
||||
const machine = Machine(
|
||||
{
|
||||
...composer.machine,
|
||||
id: composer.id
|
||||
},
|
||||
{
|
||||
services: composer.machine.services
|
||||
}
|
||||
);
|
||||
machineService = interpret(machine).onTransition((state) => {
|
||||
console.log(`${composer.id} State transitioned to: ${state.value}`);
|
||||
console.log('Context:', state.context); // Log the context
|
||||
getComposerStore(composer.id).update((storeValue) => ({
|
||||
...storeValue,
|
||||
state: state.value, // updated
|
||||
context: state.context // added
|
||||
state: state.value,
|
||||
context: state.context
|
||||
}));
|
||||
});
|
||||
machineService.start();
|
||||
@ -58,8 +68,15 @@
|
||||
if (composer?.children) {
|
||||
composer.children.forEach((child) => {
|
||||
if (child.machine) {
|
||||
const childMachine = Machine({ ...child.machine, id: child.id });
|
||||
const childMachine = Machine(
|
||||
{ ...child.machine, id: child.id },
|
||||
{
|
||||
services: child.machine.services
|
||||
}
|
||||
);
|
||||
machineService = interpret(childMachine).onTransition((state) => {
|
||||
console.log(`${child.id} State transitioned to: ${state.value}`);
|
||||
console.log('Context:', state.context); // Log the context
|
||||
getComposerStore(child.id).update((storeValue) => ({
|
||||
...storeValue,
|
||||
state: state.value, // updated
|
||||
|
Reference in New Issue
Block a user