i am trying to communicate between child and parent but it doesn't seem to be working i.e i can see the log before sendParent but parent machine doesnt seem to be recieving it. what is is wrong?
childMachine
export const applicantDetailsMachine = createMachine( { id: 'applicantDetails', initial: ApplicantDetailsState.Initial, states: { [ApplicantDetailsState.Initial]: { on: { FIELD_CHANGED: ApplicantDetailsState.InProgress, }, }, [ApplicantDetailsState.InProgress]: { always: [ { target: ApplicantDetailsState.Completed, guard: 'areAllFieldsPopulated', }, ], on: { FIELD_CHANGED: { actions: 'assignFieldValue', }, }, }, [ApplicantDetailsState.Completed]: { entry: 'childCompleted', on: { FIELD_CHANGED: { target: ApplicantDetailsState.Completed, actions: 'assignFieldValue', }, }, }, }, }, { guards: { areAllFieldsPopulated: ({ context }) => { return [ context.firstName, context.middleName, ].every(Boolean); }, }, actions: { assignFieldValue: assign(({ event }) => { return { [event.field]: event.value }; }), childCompleted: ({ context, event }) => { console.log('sending parent completed'); sendParent({ type: 'applicationDetails.completed' }); }, }, }, );
parent machine
export const appMachine = createMachine({ initial: 'applicantDetails', states: { applicantDetails: { invoke: { src: applicantDetailsMachine, }, on: { 'applicationDetails.completed': { target: 'assetDetails', actions: () => { console.log('Received completed event!'); }, }, }, }, assetDetails: {} }, });