travels3.0
Reference

Instance Methods

A task-oriented index of timeline, journal, navigation, history, and persistence methods.

This page groups the public methods by task. For exact generics, overloads, return objects, and source-linked signatures, use the generated API Reference.

State and revision

MethodReturnsNotes
getState()SCurrent live state; treat as read-only.
getRevision()numberO(1) monotonically increasing committed-event token.
mutablebooleanWhether a state-owning timeline uses mutable mode.
isTravels(value)Type guardDetects state-owning timelines from this copy of Travels.

Updates and grouping

MethodAvailabilityPurpose
setState(updater, metadata?)State-owning timelinesCommit a direct value, returned state, or draft recipe.
transaction(metadata?, fn)State-owning timelinesAtomically group synchronous operations; one root event.
batch(metadata?, fn)State-owning timelinesAlias for transaction().
recordPatches(state, entry)Controlled journalsRecord an external owner’s exact forward/inverse patch pair.
archive(metadata?)Manual timelines/journalsCommit pending updates as one entry.
canArchive()Manual timelines/journalsCheck whether work is pending.

Updater and transaction callbacks must be synchronous. Controlled journals do not expose setState(), transactions, tracking controls, or getControls().

MethodPurpose
back(amount?)Undo one or more retained entries.
forward(amount?)Redo one or more retained entries.
go(position)Jump to a retained cursor position.
canBack() / canForward()Check navigation availability.
getPosition()Read current cursor.
reset()Restore the existing instance baseline through the owner.

Navigation publishes go. Manual pending work is archived as part of successful navigation. Controlled journals delegate patch application through apply and must not record that navigation again as a new external edit.

Baseline and tracking

MethodPurpose
rebase()Keep current state and discard all past/future history.
replaceStateWithoutHistory(updater)State-owning only: update state, clear history, establish a new baseline.
pauseTracking() / resumeTracking()State-owning only: apply untracked updates around a new baseline.

Use these methods deliberately; they change what future undo and reset operations can reach.

History reads

MethodOwnership and purpose
getHistory()Shared cached read-only state timeline.
getHistorySnapshot()Detached caller-owned history states.
getPatches()Detached retained forward/inverse patch groups.
getMetadata()Metadata aligned with retained entries, including pending manual work when present.
getHistoryEntries()Forward/inverse entries plus optional metadata.
getControls()Cached frozen navigation/read-only facade for state-owning timelines.

getHistorySnapshot() copies supported runtime values without enforcing the full durable JSON contract. Strict persistence validation belongs to serialize({ strict: true }) or assertPersistenceCompatible().

Persistence

APIPurpose
serialize(options?)Return one detached versioned state/history snapshot.
assertPersistenceCompatible()Throw path-specific diagnostics for non-durable state, patches, paths, or metadata.
Travels.deserialize(input, options?)Parse, migrate, and validate a snapshot before restore.
restoreTravels(snapshot, options?)Atomically restore a state-owning timeline.
restoreTravelJournal(snapshot, options)Atomically restore an externally owned journal.

The exported Travels value is the persistence namespace, not a constructor.

Validation helpers

  • findStateCompatibilityIssues(value, options?) inspects durable-data hazards.
  • validateTravelPatches(...) validates patch structure and retained values.
  • validateTravelHistoryEntry(...) validates one forward/inverse history entry.
  • assertTravelHistoryEntryRecordable(...) preflights controlled ingress without changing journal state.
  • createPatchableTravels(...) constrains initial state statically and validates it immediately at runtime.

Subscriptions

subscribe(listener) returns an unsubscribe function. Events publish after commit; observer failures are isolated through onObserverError. Do not synchronously call mutating methods from an observer. See Observers and Events.

On this page