Skip to content

Interface: RoutableActor

API / @xmachines/play-dom-router / RoutableActor

Defined in: play-router/src/types.ts:272

The minimal actor interface that RouterBridgeBase and every framework router adapter require.

This interface, and not AbstractActor<AnyActorLogic> & Routable, gives RouterBridgeBase.actor.send the type that accepts a PlayRouteEvent directly. It therefore removes the unsafe cast (actor.send as (e: PlayRouteEvent) => void), which the weaker EventObject constraint of the actor type needed before.

Every AbstractActor subclass satisfies this interface structurally, for two reasons:

  • AbstractActor implements send(event: TEvent): void, and TEvent accepts each EventObject. Therefore it always accepts a PlayRouteEvent, which is a subtype.
  • Routable gives 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>The TC39 Signal of the current URL path of the actor, or of its state ID.play-router/src/types.ts:274
initialRoutereadonlystring | nullThe route of the initial state of the machine. The constructor fixes it. A router bridge compares it with the browser URL. It therefore separates a deep link, where the router wins, from a restore of a session, where the actor wins.play-router/src/types.ts:280

Methods

send()

send(event): void;

Defined in: play-router/src/types.ts:282

Sends a route navigation event to the actor.

Parameters

ParameterType
eventPlayRouteEvent

Returns

void