Skip to content

Behaviors

const Behaviors: object

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

Factory for building Behaviors — the functional facade over the OO Actor API. Use these combinators to compose an actor’s logic as a tree of values rather than as an imperative class.

get empty(): Behavior<never>

Sentinel: accept messages but do nothing — useful as a placeholder.

Behavior<never>

get ignore(): Behavior<never>

Sentinel: drop every incoming message silently.

Behavior<never>

get same(): Behavior<never>

Sentinel: keep the current behavior.

Behavior<never>

get stopped(): Behavior<never>

Sentinel: stop the actor.

Behavior<never>

get unhandled(): Behavior<never>

Sentinel: mark the message as unhandled (goes to dead letters).

Behavior<never>

receive<T>(handler): ReceiveBehavior<T>

Standard receive — gets both context and message.

T

(ctx, msg) => Behavior<T>

ReceiveBehavior<T>

receiveMessage<T>(handler): ReceiveBehavior<T>

Receive when you don’t need the context — message-only shortcut.

T

(msg) => Behavior<T>

ReceiveBehavior<T>

receiveWithSignal<T>(handler, onSignal): ReceiveBehavior<T>

Receive with an additional signal handler.

T

(ctx, msg) => Behavior<T>

(ctx, signal) => Behavior<T>

ReceiveBehavior<T>

setup<T>(factory): Behavior<T>

Run factory once with the actor’s context; the returned Behavior is the first one the actor adopts. Use this to capture ctx.self or spawn children in the “constructor”.

T

(ctx) => Behavior<T>

Behavior<T>

supervise<T>(child): SuperviseBuilder<T>

Wrap a behavior with a supervisor strategy. Any error thrown from the wrapped handler is routed through strategy — the behavior is restarted (reset to its initial form), stopped, resumed, or escalated.

T

Behavior<T>

SuperviseBuilder<T>

withStash<T>(capacity, factory): Behavior<T>

Expose a capacity-bounded stash buffer. The inner behavior can stash user messages (e.g. during init) and call stash.unstashAll() later.

T

number

(stash) => Behavior<T>

Behavior<T>

withTimers<T>(factory): Behavior<T>

Expose the per-actor TimerScheduler to the behavior.

T

(timers) => Behavior<T>

Behavior<T>