| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 天前 | ||
| 2 天前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 2 天前 | ||
| 3 个月前 | ||
| 3 个月前 | ||
| 3 个月前 |
Hello World (Effect)
Minimal counter actor built with the Effect SDK for Rivet Actors.
Getting Started
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/hello-world-effect
npm install
npm run dev
In a separate terminal, run the client against the server:
npm run client
Features
- Effect-native actors: Define an actor with
Actor.makeand implement it withtoLayer, returning action handlers from an Effect wake scope - Typed action protocols:
IncrementandGetCountare standaloneAction.makevalues withSchemapayloads and successes validated end to end - Typed errors across the wire:
Incrementdeclares aNegativeAmountErrorthat arrives on the caller as a real tagged instance, caught withEffect.catchTag - Persistent state: The counter value lives in persisted actor state, accessed through a
SubscriptionRef-likeStateAPI - Events: Each increment broadcasts the new count to every connected client
Implementation
The actor is split into a public contract and a server-only implementation:
- Contract (
src/actors/counter/api.ts): Declares theCounteractor and its actions - Implementation (
src/actors/counter/live.ts): Implements the wake scope, state schema, and action handlers - Server (
src/main.ts): Composes the actor layer and serves it withRegistry.serve - Client (
src/client.ts): An Effect client using the typedCounter.clientaccessor
Resources
Read more about actions, state, events, and the Effect quickstart.
License
MIT