#xstate v4 action not getting triggered on parallel promises

1 messages · Page 1 of 1 (latest)

hollow prawn
#
  id: 'myStateMachine',
  initial: 'initiate',
  context: {
    results: undefined,
    errorMessage: undefined
  },
  states: {
    initiate: {
      on : {
        startProcessing : 'fetchGenericDetails', 
        cancelRequest : 'cancelled'
    }
    },
    fetchGenericDetails: {
      type: 'parallel',
      states: {
        firstAsyncRequest: {
          invoke: {
            id: 'firstAsyncRequest',
            src : (context) => getFirstAsyncRequest(context),
          }
        },
        secondAsyncRequest: {
          invoke: {
            id: 'secondAsyncRequest',
            src : (context) => getSecondAsyncRequest(context),
          }
        },
        thirdAsyncRequest: {
          invoke: {
            id: 'thirdAsyncRequest',
            src : (context) => getThirdAsyncRequest(context),
          }
        },
      },
      onDone: "success"
    },
    success: {
      entry : 'success'
    },
    cancelled: {
      entry: 'sendCancellationNotification',
    },
  }
},{
  actions : {
    success : async (context) => {
      console.log('post :: success ===>>>',context);
    },
    sendCancellationNotification: () => {
      // Send a notification for order cancellation
      console.log('updating sendCancellationNotification ::>')

    },
  }
});```
pastel otter
#

The parallel onDone only gets called when each of the child states reach a type: 'final' grandchild state