вот код:
loadNextBatch() {
console.log('scrolldown');
this.pageIndex = this.pageIndex + 1;
this.global.getData(`/conditions/latest?start=${this.pageIndex}&length=${this.pageSize}`)
.pipe(take(1)).subscribe(res => {
const newBatch = res['data'];
if (newBatch.length === 0) {
return false;
}
this.tempThermometer.next(this.tempThermometer.getValue().concat(newBatch));
console.log(this.tempThermometer);
});
}
что я пытаюсь сделать здесь, когда нет данных от /conditions/latest?start=9&length=4
, который все еще работает до start=11 ...etc
, как заставить его остановиться. когда данных нет, их следует останавливать в start=8
, потому что в start=9
данных больше нет.
Как остановить его с start=8
, но когда есть данные на start=9
, его можно загрузить. но если на start=9
нет данных, они не должны быть загружены.
также проблема, когда я прокручивал вниз, она продолжала до start=11``
start = 12 it should be stop on
start = 8 cause there's no data on
start = 9 `` `