Skip to main content
cngx-src documentation

injectSmartDataSource

Functioncommon/data/data-source

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

Description#

Factory function for CngxSmartDataSource.

Must be called within an injection context (constructor or field initializer). Accepts either a plain Signal<T[]> or a CngxAsyncState<T[]> for full UX state integration (loading, error, refresh, empty).

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

// With async state - table shows skeleton, error, loading bar
readonly residents = injectAsyncState(() => this.api.getAll());
readonly dataSource = injectSmartDataSource(this.residents);

Signature#

injectSmartDataSource(source, options?: CngxSmartDataSourceOptions)

Parameters#

@paramsource

Returns#

CngxSmartDataSource