# Effects

These XState v4 docs are no longer maintained

XState v5 is out now! Read more about XState v5 (opens new window)

🆕 Find more about effects and actions in XState (opens new window) in our new docs.

In statecharts, "side-effects" can be grouped into two categories:

"Fire-and-forget" effects, which execute a synchronous side-effect with no events sent back to the statechart, or send an event synchronously back to the statechart:

  • Actions - single, discrete effects
  • Activities - continuous effects that are disposed when the state they were started in is exited

Invoked effects, which execute a side-effect that can send and receive events asynchronously:

  • Invoked Promises - single, discrete effects over time that may resolve or reject once, which are sent as events to the parent machine
  • Invoked Callbacks - continuous effects over time that may send multiple events, as well as listen for events sent directly to it, to/from the parent machine
  • Invoked Observables - continuous effects over time that may send multiple events triggered by messages from the observed stream
  • Invoked Machines - continuous effects represented by Machine instances that can send/receive events, but also notify the parent machine when it has reached its final state
Last Updated: 3/15/2024, 12:45:01 PM