Skip to content

Commit

Permalink
Add deprecation notice for activities
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Dec 15, 2021
1 parent 4c89828 commit 99e6882
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/guides/activities.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Activities

::: warning Deprecated
Activites are deprecated and will be removed in XState version 5. The recommended approach is to [invoke an actor](./actors.md) instead:

```diff
-activities: [(context, event) => {
- // do something
-
- return () => {/* cleanup */}
-}],
+invoke: {
+ src: (context, event) => (sendBack, receive) => {
+ // do something
+
+ return () => {/* cleanup */}
+ }
+}
```

:::

An activity is an action that occurs over time, and can be started and stopped. According to Harel's original statecharts paper:

> An activity always takes a nonzero amount of time, like beeping, displaying, or executing lengthy computations.
Expand Down

0 comments on commit 99e6882

Please sign in to comment.