I've inherited a react project using xState which is pretty unknown to me. In this machine there is a "saving" state having a few substates.
Something like this:
states : {
saving: {
id: 'saving',
initial: 'saving',
states: {
saving: {
invoke: {
src: 'updateService',
onDone: [
{
target: 'fetchSchooldays',
actions: 'setKursus',
cond: 'dateChange',
},
{
target: '#idle',
actions: 'setKursus',
},
],
onError: [
//not interesting
],
},
},
fetchSchooldays: {
invoke: {
//Not interesting
},
},
},
},
}
in the react-page I see this:
const [state, send, kursusService] = useMachine([the machine]);
Now I want to do something (just a console.log is fine) when the saving.saving (updateService) service is done but I cant figure it out.
I have been looking at documentation and examples, but I believe I need some pointers to where to begin monitoring a substate-change from outside the machine.
-- Addendum 1 ----- This morning I tried making a "between"-state :
saveDone : {
on : {
'' : [
{
target: 'fetchSchooldays',
cond: 'dateChange',
},
{ target : '#idle'}
]
}
},
I hoped I could detect this state and trigger my event and I can if I remove {target : '#idle'}, but then I won't ever hit the #idle in the root. if the {target : '#idle'} is present, it just seems to skip past this state.