Skip to main content
cngx-src documentation

CngxSmartDataSource

ClassPrimaryv0.1.0

extends DataSource

projects/common/data/data-source/smart-data-source.ts

Import#

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

Description#

A CDK DataSource that optionally integrates with CngxSort, CngxFilter, CngxSearch, and CngxPaginate present in the injection tree. Each directive is injected optionally - if absent, that processing step is skipped.

Accepts either a plain Signal<T[]> or a CngxAsyncState<T[]>. When a CngxAsyncState is provided, the data source exposes the full UX state (isLoading, isRefreshing, error, isEmpty) so the table can show skeleton rows, error states, and loading indicators.

// Plain signal
readonly dataSource = injectSmartDataSource(this.items);

// With async state - full UX lifecycle
readonly residents = injectAsyncState(() => this.api.getAll(this.filter()));
readonly dataSource = injectSmartDataSource(this.residents);
// dataSource.isLoading(), dataSource.error(), dataSource.isRefreshing()

Metadata#

Dependencies#

Index#

Instance Properties#

error#Signal
Readonly

Error from the async state, or undefined.

filteredCount#Signal
Readonly

Number of items after filtering/searching, before pagination.

isBusy#Signal
Readonly

true when any operation is running. Maps to aria-busy.

isEmpty#Signal
Readonly

true when data is empty AND no operation is running.

isFirstLoad#Signal
Readonly

true if no successful load has completed yet.

isLoading#Signal
Readonly

true during initial data load (skeleton phase).

isRefreshing#Signal
Readonly

true during refresh (data stays visible, loading bar).

Methods#

connect#Observable
disconnect#void