CngxCommitController
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 byCNGX_STATEFULbridges, 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#
Properties
Instance Properties#
SignalThe 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.
Methods#
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.variant-specific action runner (closes over the action and the intended value)
T | undefinedthe value the user clicked
T | undefinedthe 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.