mapped all services to our new me.do. prop
This commit is contained in:
parent
55b701a859
commit
c9be693408
@ -8,11 +8,12 @@
|
|||||||
let childStore;
|
let childStore;
|
||||||
|
|
||||||
$: if (me.do) {
|
$: if (me.do) {
|
||||||
childStore = me.do.subscribeComposer('@ComposerBob');
|
childStore = me.do.core.subscribeComposer('@ComposerBob');
|
||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if ($childStore && $childStore.machine.state) {
|
if ($childStore && $childStore.machine.state) {
|
||||||
|
console.log('ALICE machine service: ' + JSON.stringify(me.do.machine));
|
||||||
me.do.machine.send($childStore.machine.state);
|
me.do.machine.send($childStore.machine.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
export let machineService;
|
export let machineService;
|
||||||
|
|
||||||
const handleButton = () => {
|
const handleButton = () => {
|
||||||
console.log('learn ready machine: ' + JSON.stringify(machineService));
|
console.log('BOB machine service: ' + JSON.stringify(me.do.machine));
|
||||||
console.log('Sending TOGGLE event to the machine');
|
console.log('Sending TOGGLE event to the machine');
|
||||||
machineService.send('TOGGLE');
|
me.do.machine.send('TOGGLE');
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -35,6 +35,12 @@
|
|||||||
|
|
||||||
let machineService;
|
let machineService;
|
||||||
|
|
||||||
|
let services: Record<string, any> = {
|
||||||
|
core: coreServices,
|
||||||
|
machine: null
|
||||||
|
// otherFutureService: null,
|
||||||
|
};
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
layoutStyle = computeLayoutStyle(composer?.layout);
|
layoutStyle = computeLayoutStyle(composer?.layout);
|
||||||
|
|
||||||
@ -47,28 +53,30 @@
|
|||||||
}
|
}
|
||||||
if (composer?.machine) {
|
if (composer?.machine) {
|
||||||
const machine = Machine({ ...composer.machine, id: composer.id });
|
const machine = Machine({ ...composer.machine, id: composer.id });
|
||||||
machineService = interpret(machine).onTransition((state) => {
|
let composerMachineService = interpret(machine).onTransition((state) => {
|
||||||
getComposerStore(composer.id).update((storeValue) => ({
|
getComposerStore(composer.id).update((storeValue) => ({
|
||||||
...storeValue,
|
...storeValue,
|
||||||
machine: { state: state.value }
|
machine: { state: state.value }
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
machineService.start();
|
composerMachineService.start();
|
||||||
composer.machineService = machineService;
|
composer.me.do.machine = composerMachineService;
|
||||||
|
composer.machineService = composerMachineService;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (composer?.children) {
|
if (composer?.children) {
|
||||||
composer.children.forEach((child) => {
|
composer.children.forEach((child) => {
|
||||||
if (child.machine) {
|
if (child.machine) {
|
||||||
const childMachine = Machine({ ...child.machine, id: child.id });
|
const childMachine = Machine({ ...child.machine, id: child.id });
|
||||||
machineService = interpret(childMachine).onTransition((state) => {
|
let childMachineService = interpret(childMachine).onTransition((state) => {
|
||||||
getComposerStore(child.id).update((storeValue) => ({
|
getComposerStore(child.id).update((storeValue) => ({
|
||||||
...storeValue,
|
...storeValue,
|
||||||
machine: { state: state.value }
|
machine: { state: state.value }
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
machineService.start();
|
childMachineService.start();
|
||||||
child.machineService = machineService;
|
child.me.do.machine = childMachineService;
|
||||||
|
child.machineService = childMachineService;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -109,15 +117,16 @@
|
|||||||
}
|
}
|
||||||
return FallBack;
|
return FallBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadComponentAndService(component: IComposer) {
|
async function loadComponentAndService(component: IComposer) {
|
||||||
const componentName = component.component || 'FallBack';
|
const componentName = component.component || 'FallBack';
|
||||||
|
let services = {
|
||||||
|
core: coreServices,
|
||||||
|
machine: component.machineService || null
|
||||||
|
// otherFutureService: null,
|
||||||
|
};
|
||||||
component.me = {
|
component.me = {
|
||||||
id: component.id,
|
id: component.id,
|
||||||
do: {
|
do: services
|
||||||
...loadedServices.core,
|
|
||||||
machine: component.machineService || null
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
return await getComponent(componentName);
|
return await getComponent(componentName);
|
||||||
}
|
}
|
||||||
@ -133,8 +142,6 @@
|
|||||||
id={composer.id}
|
id={composer.id}
|
||||||
store={getComposerStore(composer.id)}
|
store={getComposerStore(composer.id)}
|
||||||
machine={composer.machine}
|
machine={composer.machine}
|
||||||
services={loadedServices}
|
|
||||||
machineService={child.machineService}
|
|
||||||
me={composer.me}
|
me={composer.me}
|
||||||
/>
|
/>
|
||||||
{/await}
|
{/await}
|
||||||
@ -150,8 +157,6 @@
|
|||||||
id={child.id}
|
id={child.id}
|
||||||
store={getComposerStore(child.id)}
|
store={getComposerStore(child.id)}
|
||||||
machine={child.machine}
|
machine={child.machine}
|
||||||
services={loadedServices}
|
|
||||||
machineService={child.machineService}
|
|
||||||
me={child.me}
|
me={child.me}
|
||||||
/>
|
/>
|
||||||
{#if child.children && child.children.length}
|
{#if child.children && child.children.length}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user