Hey folks!
For context, I have a parent machine that spawns any number of child machines. The parent machine's purpose is fetch what the structure of the form should be and submits the form changes. The child machines are responsible for capturing the changes from the user, then does an xhr call to get updated business logic. This logic may say that other parts of the interface should update.
A very rough flow:
- Parent machine is created and a fetch is made to get the structure of the page
- Parent machine spawns a child machine for each part of the page that needs it (mostly inputs, select menus, etc)
- child machine captures a change event from the user
- child machine sends change to the server and gets back a response
- this is where my question comes into play
Does the child machine say "hey, I see there are changes not just for me, I should tell my parent and let them deal with it?" or "hey. I see there are changes, let me ask the parent for each sibling and I'll let them know to change?"
As a bonus question, it feels like I should be using enqueueActions for sending events to each child machine with their respective changes, something like below, is that the best approach?
enqueueActions(({ context, event, enqueue, check }) => {
context.meta.childRefs.forEach(childRefs => {
enqueue.sendTo(childRefs, { type: 'change', data: {}})
});
})