/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/cdk/collections/data-source.ts
40 строк
2 KB
Naji
docs: replace angular.io links with angular.dev (#29734)
19 сен 2024, 13:57
Не верифицирован
19 сен 2024, 13:57
5782834
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {ConnectableObservable, Observable} from 'rxjs'; import {CollectionViewer} from './collection-viewer'; export abstract class DataSource<T> { /** * Connects a collection viewer (such as a data-table) to this data source. Note that * the stream provided will be accessed during change detection and should not directly change * values that are bound in template views. * @param collectionViewer The component that exposes a view over the data provided by this * data source. * @returns Observable that emits a new value when the data changes. */ abstract connect(collectionViewer: CollectionViewer): Observable<readonly T[]>; /** * Disconnects a collection viewer (such as a data-table) from this data source. Can be used * to perform any clean-up or tear-down operations when a view is being destroyed. * * @param collectionViewer The component that exposes a view over the data provided by this * data source. */ abstract disconnect(collectionViewer: CollectionViewer): void; } /** Checks whether an object is a data source. */ export function isDataSource(value: any): value is DataSource<any> { // Check if the value is a DataSource by observing if it has a connect function. Cannot // be checked as an `instanceof DataSource` since people could create their own sources // that match the interface, but don't extend DataSource. We also can't use `isObservable` // here, because of some internal apps. return value && typeof value.connect === 'function' && !(value instanceof ConnectableObservable); }