Features
- Effect-wrapped actions - Write actor actions using Effect generators for composable, type-safe logic
- Actor context as Effect service - Access actor state, broadcast, and other context via Effect's dependency injection
- Structured logging - Effect-based logging utilities integrated with actor logging
Implementation
This example provides Effect bindings for actors. The core implementation wraps the actor context in Effect services, allowing you to write actions using Effect's generator syntax.
Key files:
src/actors/fetch-actor.ts- Multi-step workflows with error handlingsrc/actors/queue-processor.ts- Background queue processing with therunhandler
Example usage:
import { actor } from "rivetkit";
import { Action } from "@rivetkit/effect";
export const counter = actor({
state: { count: 0 },
actions: {
increment: Action.effect(function* (c, x: number) {
yield* Action.updateState(c, (s) => { s.count += x; });
const s = yield* Action.state(c);
yield* Action.broadcast(c, "newCount", s.count);
return s.count;
}),
},
});


