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:
spawntakes 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.
Type Parameters
Section titled “Type Parameters”T
Properties
Section titled “Properties”
readonlylog:Logger
Defined in: src/typed/TypedActorContext.ts:19
readonlypath:ActorPath
Defined in: src/typed/TypedActorContext.ts:17
readonlyself:ActorRef<T>
Defined in: src/typed/TypedActorContext.ts:16
system
Section titled “system”
readonlysystem:ActorSystem
Defined in: src/typed/TypedActorContext.ts:18
timers
Section titled “timers”
readonlytimers:TimerScheduler<T>
Defined in: src/typed/TypedActorContext.ts:62
Per-actor timers.
Methods
Section titled “Methods”setDisplayName()
Section titled “setDisplayName()”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.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
spawn()
Section titled “spawn()”spawn<
U>(behavior,name?):ActorRef<U>
Defined in: src/typed/TypedActorContext.ts:37
Spawn a typed child actor with the given Behavior.
Type Parameters
Section titled “Type Parameters”U
Parameters
Section titled “Parameters”behavior
Section titled “behavior”Behavior<U>
string
Returns
Section titled “Returns”ActorRef<U>
stop()
Section titled “stop()”stop(
ref):void
Defined in: src/typed/TypedActorContext.ts:40
Stop a watched child or self.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
unwatch()
Section titled “unwatch()”unwatch(
ref):void
Defined in: src/typed/TypedActorContext.ts:59
Stop watching — whether registered via watch or watchWith.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
watch()
Section titled “watch()”watch(
ref):void
Defined in: src/typed/TypedActorContext.ts:43
Death-watch another actor — you’ll receive a Signal when it terminates.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
watchWith()
Section titled “watchWith()”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.
Parameters
Section titled “Parameters”message
Section titled “message”T
Returns
Section titled “Returns”void
