Skip to content

v0.1.2 - ActorRef Interface & Type Improvements

Latest

Choose a tag to compare

@PaulJPhilp PaulJPhilp released this 03 Nov 23:22

What's New

✨ New Features

  • ActorRef<M, R> Interface: Added proper TypeScript interface for actor references
    • Generic message type M and requirements type R
    • send(message: M): Effect.Effect<void, Error, R> method
    • Full Effect integration for type-safe messaging

🏗️ Architecture Improvements

  • Enhanced Type Safety: Better TypeScript inference across the actor system
  • Module Organization: Improved export structure in actor/index.ts
  • Effect Integration: Proper Effect imports and usage patterns

📦 Package

  • Published to npm as effect-actor-pauljphilp@0.1.2

🧪 Testing

  • All 34 tests passing
  • Comprehensive coverage of actor functionality

Usage Example

import { Actor } from 'effect-actor-pauljphilp'

const actor: ActorRef<{ type: 'increment' }> = await Actor.make({
  initialState: 0,
  receive: (count, msg) => 
    msg.type === 'increment' 
      ? Effect.succeed(count + 1)
      : Effect.succeed(count)
}).pipe(Effect.runPromise)

await actor.send({ type: 'increment' })