Skip to content

Commit

Permalink
Merge pull request #2878 from statelyai/davidkpiano/activity-deprecat…
Browse files Browse the repository at this point in the history
…ion-docs

Docs: Add deprecation notice for activities
  • Loading branch information
davidkpiano authored Dec 15, 2021
2 parents 4c89828 + 99e6882 commit 89fcc6d
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 89fcc6d

Please sign in to comment.