From 99e688225e313cc3ccfa4ead30917c3c7037838b Mon Sep 17 00:00:00 2001 From: David Khourshid Date: Tue, 14 Dec 2021 17:43:01 -0800 Subject: [PATCH] Add deprecation notice for activities --- docs/guides/activities.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/guides/activities.md b/docs/guides/activities.md index 4149faf8de..0ea28df799 100644 --- a/docs/guides/activities.md +++ b/docs/guides/activities.md @@ -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.