Skip to content
English

TypedActorContext

Defined in: src/typed/TypedActorContext.ts:15

Typed variant of ActorContext — the runtime API exposed to Behaviors. Differs from the untyped ActorContext in two ways:

  • spawn takes a Behavior instead of an actor class or factory
  • there is no become/unbecome — behavior changes happen by returning a new Behavior from the message handler.

T

readonly log: Logger

Defined in: src/typed/TypedActorContext.ts:19


readonly path: ActorPath

Defined in: src/typed/TypedActorContext.ts:17


readonly self: ActorRef<T>

Defined in: src/typed/TypedActorContext.ts:16


readonly system: ActorSystem

Defined in: src/typed/TypedActorContext.ts:18


readonly timers: TimerScheduler<T>

Defined in: src/typed/TypedActorContext.ts:62

Per-actor timers.

setDisplayName(name): void

Defined in: src/typed/TypedActorContext.ts:34

Name this actor in log lines and in the DevTools tree (#891). Every Behavior runs inside the same TypedActor class, so there is no subclass to override Actor.displayName() on — this is the way in:

Behaviors.setup<Command>((context) => {
context.setDisplayName(`User(${userId})`);
return Behaviors.receive(...);
});

Takes effect on the next record. Purely cosmetic — the path stays the identity everywhere that routes or correlates.

string

void


spawn<U>(behavior, name?): ActorRef<U>

Defined in: src/typed/TypedActorContext.ts:37

Spawn a typed child actor with the given Behavior.

U

Behavior<U>

string

ActorRef<U>


stop(ref): void

Defined in: src/typed/TypedActorContext.ts:40

Stop a watched child or self.

ActorRef

void


unwatch(ref): void

Defined in: src/typed/TypedActorContext.ts:59

Stop watching — whether registered via watch or watchWith.

ActorRef

void


watch(ref): void

Defined in: src/typed/TypedActorContext.ts:43

Death-watch another actor — you’ll receive a Signal when it terminates.

ActorRef

void


watchWith(ref, message): void

Defined in: src/typed/TypedActorContext.ts:56

Death-watch ref and receive message when it terminates, instead of a terminated Signal.

The difference is which handler runs: a Signal goes to the onSignal argument of Behaviors.receive, where every watched death of every kind arrives together and has to be told apart by ref; a watchWith message is a plain T and lands in the ordinary receive handler, so the protocol itself already says what died. Last call wins over a previous watch/watchWith of the same ref.

ActorRef

T

void