You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add runInBackground method and update actor lifecycle docs (#2842)
<!-- Please make sure there is an issue that this PR is correlated to. -->
## Changes
<!-- If there are frontend changes, please include screenshots. -->
Actors can be shut down gracefully with `c.shutdown()`. Clients will be gracefully disconnected.
474
+
_Destroying actors is not available yet._
475
+
476
+
## Advanced
477
+
478
+
### Running Background Tasks
479
+
480
+
The `c.runInBackground` method allows you to execute promises asynchronously without blocking the actor's main execution flow. The actor is prevented from sleeping while the promise passed to `runInBackground` is still active. This is useful for fire-and-forget operations where you don't need to wait for completion.
481
+
482
+
Common use cases:
483
+
-**Analytics and logging**: Send events to external services without delaying responses
484
+
-**State sync**: Populate external databases or APIs with updates to actor state in the background
When extracting logic from lifecycle hooks or actions into external functions, you'll often need to define the type of the context parameter. Rivet provides helper types that make it easy to extract and pass these context types to external functions.
0 commit comments