@infinite-list/data-model
Advanced tools
Comparing version 0.2.45-recycle-group.41 to 0.2.45-recycle-group.42
@@ -25,3 +25,2 @@ import Batchinator from '@x-oasis/batchinator'; | ||
private _renderState; | ||
private _onUpdateDimensionItemsMetaChangeBatchinator; | ||
private _onItemsCountChangedBatchinator; | ||
@@ -91,3 +90,3 @@ recalculateDimensionsIntervalTreeBatchinator: Batchinator; | ||
calculateDimensionsIndexRange(): void; | ||
onItemsCountChanged(useCache?: boolean): void; | ||
onItemsCountChanged(): void; | ||
updateChildDimensionsOffsetInContainer(): void; | ||
@@ -94,0 +93,0 @@ recalculateDimensionsIntervalTree(): void; |
@@ -17,4 +17,4 @@ import Heap from '@x-oasis/heap'; | ||
getNewPositionForValue(value: number): number; | ||
getMinValue(): any; | ||
getMaxValue(): any; | ||
getMinValue(): number; | ||
getMaxValue(): number; | ||
setPositionValue(position: number, value: number): void; | ||
@@ -21,0 +21,0 @@ replaceFurthestValuePosition(lowValue: number, highValue: number, newValue: number, useMinValueFn?: (options: { |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.2.45-recycle-group.41", | ||
"version": "0.2.45-recycle-group.42", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -5,2 +5,5 @@ import ListGroupDimensions from '../ListGroupDimensions'; | ||
import { describe, expect, it, test, vi, afterEach } from 'vitest'; | ||
vi.useFakeTimers(); | ||
const buildData = (count: number) => | ||
@@ -22,9 +25,9 @@ new Array(count).fill(1).map((v, index) => ({ | ||
const startInspection = ListGroupDimensions.prototype.startInspection; | ||
// https://jestjs.io/docs/es6-class-mocks#mocking-a-specific-method-of-a-class | ||
vi.spyOn(ListGroupDimensions.prototype, 'startInspection').mockImplementation( | ||
function (...args) { | ||
startInspection.call(this); | ||
} | ||
); | ||
// const startInspection = ListGroupDimensions.prototype.startInspection; | ||
// // https://jestjs.io/docs/es6-class-mocks#mocking-a-specific-method-of-a-class | ||
// vi.spyOn(ListGroupDimensions.prototype, 'startInspection').mockImplementation( | ||
// function (...args) { | ||
// startInspection.call(this); | ||
// } | ||
// ); | ||
@@ -1086,4 +1089,4 @@ describe('basic', () => { | ||
]); | ||
listGroupDimensions.startInspection(); | ||
const { heartBeat } = listGroupDimensions.getInspectAPI(); | ||
listGroupDimensions.inspector.startInspection(); | ||
const { heartBeat } = listGroupDimensions.inspector.getAPI(); | ||
const inspectingTime = Date.now() + 1; | ||
@@ -1090,0 +1093,0 @@ heartBeat({ listKey: 'list_1', inspectingTime }); |
@@ -7,2 +7,4 @@ import SortedItems from '../SortedItems'; | ||
vi.useFakeTimers(); | ||
vi.spyOn(Batchinator.prototype, 'schedule').mockImplementation(function ( | ||
@@ -9,0 +11,0 @@ ...args |
@@ -61,3 +61,3 @@ import Batchinator from '@x-oasis/batchinator'; | ||
private _renderState: ListRenderState; | ||
private _onUpdateDimensionItemsMetaChangeBatchinator: Batchinator; | ||
// private _onUpdateDimensionItemsMetaChangeBatchinator: Batchinator; | ||
private _onItemsCountChangedBatchinator: Batchinator; | ||
@@ -142,6 +142,2 @@ public recalculateDimensionsIntervalTreeBatchinator: Batchinator; | ||
this._store = createStore<ReducerResult>(); | ||
this._onUpdateDimensionItemsMetaChangeBatchinator = new Batchinator( | ||
this.onUpdateDimensionItemsMetaChange.bind(this), | ||
100 | ||
); | ||
@@ -518,3 +514,3 @@ this._inspector = new Inspector({ | ||
this.inspector.remove(listKey); | ||
this._onItemsCountChangedBatchinator.schedule(); | ||
this.onItemsCountChanged(); | ||
} | ||
@@ -562,4 +558,2 @@ } | ||
// this.setListData(listKey, data); | ||
let onEndReachedCleaner = null; | ||
@@ -573,2 +567,9 @@ | ||
// for performance boost. only reflow data when less than initial number; | ||
if (this.getData().length < this.initialNumToRender) { | ||
this.onItemsCountChanged(); | ||
} else { | ||
this._onItemsCountChangedBatchinator.schedule(); | ||
} | ||
return { | ||
@@ -618,3 +619,7 @@ dimensions, | ||
onItemsCountChanged(useCache = false) { | ||
/** | ||
* Important!!! : data change should be reflect immediately. but resolve state could be deferred. | ||
* So this.updateScrollMetrics actually is a batch operation .. | ||
*/ | ||
onItemsCountChanged() { | ||
this.reflowFlattenData(); | ||
@@ -624,3 +629,3 @@ this.calculateDimensionsIndexRange(); | ||
this.updateChildDimensionsOffsetInContainer(); | ||
this.updateScrollMetrics(this._scrollMetrics, { useCache }); | ||
this.updateScrollMetrics(); | ||
} | ||
@@ -664,3 +669,4 @@ | ||
this._inspector.remove(key); | ||
this._onItemsCountChangedBatchinator.schedule(); | ||
this.onItemsCountChanged(); | ||
// this._onItemsCountChangedBatchinator.schedule(); | ||
} | ||
@@ -694,2 +700,8 @@ } | ||
this._inspector.push(key); | ||
// for performance boost. only reflow data when less than initial number; | ||
if (this.getData().length < this.initialNumToRender) { | ||
this.onItemsCountChanged(); | ||
} else { | ||
this._onItemsCountChangedBatchinator.schedule(); | ||
} | ||
return { | ||
@@ -741,4 +753,4 @@ dimensions, | ||
// remove callback一般会慢,如果不做延迟的话,你会发现data可能存在已经unmount的数据 | ||
// this.onItemsCountChanged(); | ||
this._onItemsCountChangedBatchinator.schedule(); | ||
this.onItemsCountChanged(); | ||
// this._onItemsCountChangedBatchinator.schedule(); | ||
} else if (changedType === KeysChangedType.Reorder) { | ||
@@ -745,0 +757,0 @@ this.reflowFlattenData(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2312340
113
26220