What is the expected behavior?
The following implementation of DataSource#connect should work.
connect(collectionViewer: CollectionViewer): Observable<ProjectListItem[]> {
return collectionViewer.viewChange.pipe(
switchMap(({ start, end }) => this.fetchData(start, end))
);
}
What is the current behavior?
The above code does not work while the following works.
connect(collectionViewer: CollectionViewer): Observable<ProjectListItem[]> {
return collectionViewer.viewChange.pipe(
startWith({ start: 0, end: 0 }), // add this line
switchMap(({ start, end }) => this.fetchData(start, end))
);
}
IMO this behavior is really confusing.
What are the steps to reproduce?
https://stackblitz.com/edit/angular-nzrgbv?file=app%2Fcdk-virtual-scroll-data-source-example.ts