Skip to main content
cngx-src documentation

CngxCommitController

Interface

projects/common/data/commit/commit-controller.ts

Import#

import { CngxCommitController } from '@cngx/common/data'

Description#

Encapsulated state machine for the async-commit lifecycle shared by every cngx feature that has a "perform-an-async-write-then-update- the-source-signal" flow (select family, stepper, future wizards).

Owns:

  • the CngxAsyncState<T | undefined> slot consumed by CNGX_STATEFUL bridges, commit-error templates, and the pending-row spinner;
  • begin / cancel orchestration with monotonic supersede semantics;
  • the "intended value" signal that drives the pending-spinner on the specific row / step the user just clicked.

The controller is intentionally not an Angular service or provider. It's a plain factory so it works in any injection context (including outside Angular, for headless tests).

Index#

Instance Properties#

intendedValue#Signal
Readonly

The most recent intended value — what the user was trying to commit. Used by the option-row spinner and the commit-error template context to identify which option the failure belongs to.

isCommitting#Signal
Readonly

true while a commit is in flight.

Readonly

Read-only async-state view of the commit lifecycle.

Methods#

begin#void
begin(runner: CngxCommitRunner<T>, intended: T | undefined, previous: T | undefined, handlers: CngxCommitBeginHandlers<T>)

Start a new commit. Supersedes any in-flight commit: the previous runner's cancel handle fires synchronously, and the previous outcome callbacks become no-ops if they fire late.

            action and the intended value)
            updates its own state and calls these; it does
            NOT touch external value signals, panel open
            state, or component outputs.
@paramrunnerCngxCommitRunner

variant-specific action runner (closes over the action and the intended value)

@paramintendedT | undefined

the value the user clicked

@parampreviousT | undefined

the value to roll back to on error

success/error routes — the controller only updates its own state and calls these; it does NOT touch external value signals, panel open state, or component outputs.

cancel#void

Abort the currently in-flight commit without firing callbacks. Use when the host component is destroyed or the commit-action input changes mid-flight.