in packages/attribute-slicer/src/AttributeSlicer.ts [887:931]
protected raiseLoadMoreData(isNewSearch: boolean): void {
const item: { result?: PromiseLike<ISlicerItem[]> } = {};
this.events.raiseEvent(
"loadMoreData",
item,
isNewSearch,
this.searchString,
);
if (item.result) {
this.loadingMoreData = true;
const promise: PromiseLike<void | ISlicerItem[]> & {
cancel?: boolean;
} = (this.loadPromise = item.result.then(
(items: ISlicerItem[]) => {
// if this promise hasn't been cancelled
if (!promise || !promise.cancel) {
this.loadPromise = undefined;
if (isNewSearch) {
this.data = items;
} else {
this.data = this.data.concat(items);
}
// make sure we don't need to load more after this,
// in case it doesn't all fit on the screen
setTimeout(() => {
this.checkLoadMoreData();
if (!this.loadPromise) {
this.loadingMoreData = false;
}
}, 10);
return items;
}
},
() => {
// If we are rejected, we don't need to clear the data,
// this just means the retrieval for more data failed, leave the data
// this.data = [];
this.loadingMoreData = false;
},
));
}
this.loadingMoreData = false;
}