Skip to main content
cngx-src documentation

createTabRouterCommit

Functioncommon/tabsv0.1.0

projects/common/tabs/router-commit.ts

Description#

Builds a CngxTabsCommitAction that gates a tab switch through @angular/router. The action navigates to the target tab's route and resolves on this navigation's own navigate() promise:

  • resolved true (NavigationEnd) → true (commit the switch)
  • resolved false (NavigationCancel - a CanDeactivate guard blocked, or a newer navigation superseded this one) → false
  • rejected (NavigationError - guard/resolver threw) → false

Routed tabs reuse the presenter's commit lifecycle verbatim - the router navigation is simply the async op.
In pessimistic mode the active tab follows the resolved route, so a cancelled guard keeps the old tab with zero extra gate machinery. Correlating on the promise (not router.events) means a concurrent unrelated navigation's outcome can never resolve this commit; the commit controller's cancel() closes the subscriber on supersede, and a late promise resolution lands on the closed subscriber and is dropped by RxJS itself.

Signature#

createTabRouterCommit(opts: CngxTabRouterCommitOptions)

Parameters#

Returns#

CngxTabsCommitAction