Skip to content

Interface: RoutableActor

API / @xmachines/play-router / RoutableActor

Defined in: types.ts:259

Minimal actor interface required by RouterBridgeBase and all framework router adapters.

Using this interface instead of AbstractActor<AnyActorLogic> & Routable lets RouterBridgeBase.actor.send be typed to accept PlayRouteEvent directly — eliminating the unsafe (actor.send as (e: PlayRouteEvent) => void) cast that existed when the actor was typed with the weaker EventObject constraint.

All AbstractActor subclasses satisfy this interface structurally because:

  • AbstractActor implements send(event: TEvent): void where TEvent accepts any EventObject, so PlayRouteEvent (a subtype) is always accepted.
  • Routable provides currentRoute and initialRoute.

Example

import type { RoutableActor } from "@xmachines/play-router";
class MyBridge extends RouterBridgeBase {
constructor(actor: RoutableActor, routeMap: RouteMap) {
super(actor, routeMap);
}
}

Extended by

Properties

PropertyModifierTypeDescriptionDefined in
currentRoutereadonlyComputed<string | null>TC39 Signal exposing the actor’s current URL path (or state ID).types.ts:261
initialRoutereadonlystring | nullThe route derived from the machine’s initial state — fixed at construction. Router bridges compare this against the browser URL to distinguish a deep-link (router wins) from a session restore (actor wins).types.ts:267

Methods

send()

send(event): void;

Defined in: types.ts:269

Send a route navigation event to the actor.

Parameters

ParameterType
eventPlayRouteEvent

Returns

void