LinearOnboardingOrchestrator

Drives one linear onboarding run at a time. It walks a LinearOnboardingPlan's steps, skips any whose LinearOnboardingStep.precondition is false, and publishes the current position as state. A step can branch by returning a LinearOnboardingTransition. LinearOnboardingTransition.SwitchTo pushes a side plan, and LinearOnboardingTransition.ReturnAndAdvance pops back to its caller.

It never touches UI. Renderers observe state and report user actions through onEvent.

Implementations are thread-safe and run calls one at a time. Step and plan callbacks run inside that same serialization, so they must not call back into startPlan or onEvent. A reentrant call throws IllegalStateException instead of deadlocking.

Properties

Link copied to clipboard
abstract val state: StateFlow<LinearOnboardingState>

Where the run currently is. It starts as LinearOnboardingState.NotStarted, becomes LinearOnboardingState.InProgress on the first startPlan, and ends at LinearOnboardingState.Completed or LinearOnboardingState.Skipped. Starting again from a terminal state goes back to InProgress. Once a run has started it is never NotStarted again.

Functions

Link copied to clipboard
abstract suspend fun onEvent(event: LinearOnboardingEvent)

Passes event to the current step's LinearOnboardingStep.transition and applies the result. Does nothing before the run starts or after it ends.

Link copied to clipboard
abstract suspend fun startPlan(plan: LinearOnboardingPlan)

Starts a run with plan from its first eligible step. state is up to date by the time this returns. You can call it from NotStarted or a terminal state. It does nothing while a run is already in progress.