Skip to content

with-view

API / @xmachines/play-xstate / with-view

The view capability of an XState actor, as a mixin.

PlayerActor holds state and send, and nothing about a view. This module adds currentView, which is what Viewable of @xmachines/play-view asks for and what every renderer reads.

It is a SEPARATE entry point, @xmachines/play-xstate/view, and the core imports it never. @xmachines/play-view is an OPTIONAL peer of this package for the same reason: an application that renders no view installs neither that package nor the json-render types that it names.

Example

import { definePlayer, PlayerActor, compose } from "@xmachines/play-xstate";
import { withRouting } from "@xmachines/play-xstate/routing";
import { withView } from "@xmachines/play-xstate/view";
const createPlayer = definePlayer({
machine,
actor: compose(PlayerActor, withRouting, withView),
});

Functions