History Behavior
History powers deterministic back navigation.
history vs visited
history: previous-step stack used byHISTORY_TARGET.visited: unique ordered list of all reached steps.
visited survives history trimming.
HISTORY_TARGET Resolution
When transition target is HISTORY_TARGET:
- Read latest entry from history.
- Skip invalid entries.
- Move to first valid prior step.
- Remove consumed entry from history.
If no valid entry exists, machine stays on current step.
Common Back Pattern
import { HISTORY_TARGET } from "@rxova/journey-core";
{ from: "*", event: "back", to: HISTORY_TARGET }
Capacity and Trimming
Defaults:
maxHistory = 50maxHistory = nulldisables trimming.
onOverflow gets:
previousnexttrimmedreason:"auto" | "hydrate" | "manual"
Manual APIs
machine.trimHistory(10);
machine.clearHistory();
Design Guidance
- Keep global back rule near top-level transitions.
- For restricted back paths, add specific transitions before wildcard back.
- Use
visitedfor analytics/progress, nothistory.