data-source.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { Observable } from 'rxjs';
  9. import { CollectionViewer } from './collection-viewer';
  10. export declare abstract class DataSource<T> {
  11. /**
  12. * Connects a collection viewer (such as a data-table) to this data source. Note that
  13. * the stream provided will be accessed during change detection and should not directly change
  14. * values that are bound in template views.
  15. * @param collectionViewer The component that exposes a view over the data provided by this
  16. * data source.
  17. * @returns Observable that emits a new value when the data changes.
  18. */
  19. abstract connect(collectionViewer: CollectionViewer): Observable<T[] | ReadonlyArray<T>>;
  20. /**
  21. * Disconnects a collection viewer (such as a data-table) from this data source. Can be used
  22. * to perform any clean-up or tear-down operations when a view is being destroyed.
  23. *
  24. * @param collectionViewer The component that exposes a view over the data provided by this
  25. * data source.
  26. */
  27. abstract disconnect(collectionViewer: CollectionViewer): void;
  28. }
  29. /** Checks whether an object is a data source. */
  30. export declare function isDataSource(value: any): value is DataSource<any>;