Let's take the todo app idea.
I have a few machines.
AuthMachine, TodosMachine, TodoMachine
Like in the examples, TodosMachine keeps the array of Todos where TodoMachine is around the display/editing of a single Todo.
Let's also say that we have a drag/drop/sortable state for display. We will call it SortableMachine.
Finally, Todos might get a push update from the server. So in TodosMachine there is a subscription that might update the Todos list.
Here is where I get confused.
- We only want to subscribe to updates on server when AuthMachine is in the "logged in" state.
- When dragging or modifying a todo, we want to batch the server updates. We don't want to drop them, but only apply them after the drag event.
I'll pause there, as there is complexity in event conflicts (server and client both make changes to a todo) That seems like a smaller aspect state machine in resolving that though.
My big question is - how do I get data from one machine from another? I want to only subscribe to server todo updates when auth is logged in. want to add a change stack, but only take actions on that stack when todos are not being modified.