Invoke an XState Service when Entering a State

Share this video with your friends

Send Tweet

It can be tedious to create a paired success and failure event for each external action that a state machine triggers. Instead xstate can integrate directly with a promise and respond to the resolve or reject status of the promise itself.

Sébastien BARRE
Sébastien BARRE
~ 3 years ago

Thanks for this series. There is a typo here. Once you convert fetchData from an action to a service, it should then be relocated to the services: property in the machine options in App.tsx, instead of the previous actions: property.

Lucas Minter
Lucas Minter
~ 3 years ago

Hey Sébastien! You are correct. I went ahead and got those errors in the transcripts fixed.