1. 8
    Replace Inline Functions with String Shorthands
    1m 34s

Replace Inline Functions with String Shorthands

InstructorKyle Shevlin

Share this video with your friends

Send Tweet

It is considered best practice to use the string shorthand for actions, guards, and more when configuring an XState Machine. We do this by providing a second argument to the Machine factory function: the options object.

On this object, we can define our actions, guards, activities, services and more. We then refer to the name of these functions with a string of the same name.

//...
broken: {
  entry: ['logBroken']
}
//...
// In the options object
{
  actions: {
    logBroken: (context, event) => { console.log('yo I am broke') }
  }
}
Zachary
~ 5 years ago

This was already covered in the previous video.