Rxova
Skip to content

Overview

Journey is a small, framework-independent runtime for multi-step flows. A journey owns the current step, context, history, lifecycle status, and async transition state. Your UI reads one immutable snapshot and drives the machine through a stable set of methods.

Component-local step state works until branching, async gates, backtracking, lifecycle outcomes, and observation must agree. Journey keeps those rules in one runtime so every consumer reads the same committed state and realized path.

ShapeFactoryUse it when
LinearcreateLinearJourneySteps normally follow a declared order.
GraphcreateGraphJourneyEvents, guards, or branches decide the next step.

Both factories use the same snapshot/event runtime. The difference is in definition syntax, navigation rules, and the fields added to their discriminated snapshots.

import { createLinearJourney } from "@rxova/journey-core";
const checkout = createLinearJourney({
steps: ["account", "shipping", "review"] as const,
context: { email: "" }
});
console.log(checkout.getSnapshot().currentStep?.id); // "account"

The machine object is stable. Changing state lives in getSnapshot().

GroupPurpose
controlsStart, pause, resume, complete, terminate, or restart a run.
navigateMove by id or through the realized timeline.
subscriptionsObserve selected snapshot values or named lifecycle events.
contextApply an immutable context update.
pluginsAccess APIs contributed by registered plugins.
sendDispatch a typed event on graph journeys only.
  • Snapshots are the read model. Context, status, history, async state, metadata, and derived fields are read together.
  • Definitions are data. Linear and graph definitions can be created, tested, and reused before a runtime exists.
  • Navigation is explicit. Reaching a final step does not complete the journey; call machine.controls.complete() when the product flow is done.
  • Linear has an escape hatch. Occasional goToStepById jumps are allowed and ungated. When named jumps or branching become normal behavior, convert the definition to graph mode.
  • Work and effects have clear timing. Next/previous work can stop before commit. onLeave, onTransition, and onEnter are awaited after commit.
  • Plugins observe. They receive a read-only host and add namespaced machine and snapshot data.