Skip to content

Latest commit

History

History
10 lines (8 loc) 路 841 Bytes

08-execute-code-when-entering-and-exiting-states-using-activities.md

File metadata and controls

10 lines (8 loc) 路 841 Bytes

Execute Code when Entering and Exiting States using Activities

Activities

馃挵 An activity is an action that occurs over time, and can be started and stopped

  • Activities are great place for observables, which need to be subscribed and unsubscribed, or a setInterval which needs to be connected, or a websocket that needs to be connected and disconnected, etc.
  • In xstate activities are specified on the activities key of a machine state.
  • Transitioning within the same parent state will not restart its activities, but be mindful that it might start new activities.