@infinite-list/data-model
Advanced tools
Comparing version 0.2.33 to 0.2.34
@@ -19,2 +19,3 @@ import SelectValue from '@x-oasis/select-value'; | ||
private _recycleBufferedCount; | ||
private _canIUseRIC; | ||
constructor(props: { | ||
@@ -33,2 +34,3 @@ id: string; | ||
recycleEnabled?: boolean; | ||
canIUseRIC?: boolean; | ||
}); | ||
@@ -39,2 +41,3 @@ get initialNumToRender(): number; | ||
get recycleBufferedCount(): number; | ||
get canIUseRIC(): boolean; | ||
updateReservedIndices(): void; | ||
@@ -41,0 +44,0 @@ get persistanceIndices(): Array<number>; |
@@ -16,2 +16,3 @@ import ItemMeta from './ItemMeta'; | ||
private _onRender; | ||
private _canIUseRIC; | ||
constructor(props: DimensionProps); | ||
@@ -18,0 +19,0 @@ get length(): number; |
@@ -14,2 +14,3 @@ import ItemMetaStateEventHelper from './ItemMetaStateEventHelper'; | ||
readonly _ownerId: string; | ||
readonly _canIUseRIC?: boolean; | ||
constructor(props: { | ||
@@ -26,2 +27,3 @@ onViewable?: StateEventListener; | ||
isInitialItem?: boolean; | ||
canIUseRIC?: boolean; | ||
}); | ||
@@ -28,0 +30,0 @@ get id(): string; |
@@ -13,4 +13,4 @@ import { StateEventListener } from './types'; | ||
private _callbackId; | ||
private _setupCallbackMs; | ||
private _callbackStartMinMs; | ||
readonly _canIUseRIC: boolean; | ||
constructor(props: { | ||
@@ -22,2 +22,3 @@ key: string; | ||
once?: boolean; | ||
canIUseRIC?: boolean; | ||
}); | ||
@@ -24,0 +25,0 @@ remover(listener: StateEventListener, key?: string): () => void; |
@@ -20,2 +20,3 @@ import BaseDimensions from '../BaseDimensions'; | ||
horizontal?: boolean; | ||
canIUseRIC?: boolean; | ||
onUpdateItemLayout?: Function; | ||
@@ -67,2 +68,3 @@ onUpdateIntervalTree?: Function; | ||
dispatchMetricsThreshold?: number; | ||
canIUseRIC?: boolean; | ||
} & BaseDimensionsProps & OnEndReachedHelperProps; | ||
@@ -95,5 +97,7 @@ export declare type ItemsDimensionsProps = BaseDimensionsProps; | ||
indexKeys: Array<string>; | ||
canIUseRIC?: boolean; | ||
} & BaseDimensionsProps; | ||
export declare type DimensionProps = { | ||
id: string; | ||
canIUseRIC?: boolean; | ||
onRender?: Function; | ||
@@ -100,0 +104,0 @@ horizontal?: boolean; |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.2.33", | ||
"version": "0.2.34", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -32,2 +32,3 @@ import { | ||
private _recycleBufferedCount: number; | ||
private _canIUseRIC: boolean; | ||
@@ -48,2 +49,4 @@ constructor(props: { | ||
recycleEnabled?: boolean; | ||
canIUseRIC?: boolean; | ||
}) { | ||
@@ -57,2 +60,3 @@ const { | ||
getContainerLayout, | ||
canIUseRIC, | ||
stickyHeaderIndices = [], | ||
@@ -87,2 +91,3 @@ windowSize = WINDOW_SIZE, | ||
this.stickyHeaderIndices = stickyHeaderIndices; | ||
this._canIUseRIC = canIUseRIC; | ||
} | ||
@@ -106,2 +111,6 @@ | ||
get canIUseRIC() { | ||
return this._canIUseRIC; | ||
} | ||
updateReservedIndices() { | ||
@@ -108,0 +117,0 @@ const indices = new Set( |
@@ -22,2 +22,3 @@ import ItemMeta from './ItemMeta'; | ||
private _onRender: Function; | ||
private _canIUseRIC: boolean; | ||
@@ -29,2 +30,3 @@ constructor(props: DimensionProps) { | ||
onRender, | ||
canIUseRIC, | ||
listGroupDimension, | ||
@@ -41,2 +43,3 @@ initialStartIndex, | ||
this._ignoredToPerBatch = !!ignoredToPerBatch; | ||
this._canIUseRIC = canIUseRIC; | ||
this._meta = new ItemMeta({ | ||
@@ -46,2 +49,3 @@ key: this.id, | ||
owner: this, | ||
canIUseRIC: this._canIUseRIC, | ||
}); | ||
@@ -196,2 +200,3 @@ this.resolveConfigTuplesDefaultState = | ||
owner: this, | ||
canIUseRIC: this._canIUseRIC, | ||
}); | ||
@@ -198,0 +203,0 @@ return this._meta; |
@@ -12,3 +12,3 @@ "use strict"; | ||
this._reservedIndices = []; | ||
var id = props.id, recycleThreshold = props.recycleThreshold, _a = props.persistanceIndices, persistanceIndices = _a === void 0 ? [] : _a, _b = props.recycleEnabled, recycleEnabled = _b === void 0 ? false : _b, _c = props.horizontal, horizontal = _c === void 0 ? false : _c, getContainerLayout = props.getContainerLayout, _d = props.stickyHeaderIndices, stickyHeaderIndices = _d === void 0 ? [] : _d, _e = props.windowSize, windowSize = _e === void 0 ? common_1.WINDOW_SIZE : _e, _f = props.recycleBufferedCount, recycleBufferedCount = _f === void 0 ? common_1.RECYCLE_BUFFERED_COUNT : _f, _g = props.maxToRenderPerBatch, maxToRenderPerBatch = _g === void 0 ? common_1.MAX_TO_RENDER_PER_BATCH : _g, _h = props.initialNumToRender, initialNumToRender = _h === void 0 ? common_1.INITIAL_NUM_TO_RENDER : _h, _j = props.onEndReachedThreshold, onEndReachedThreshold = _j === void 0 ? common_1.ON_END_REACHED_THRESHOLD : _j; | ||
var id = props.id, recycleThreshold = props.recycleThreshold, _a = props.persistanceIndices, persistanceIndices = _a === void 0 ? [] : _a, _b = props.recycleEnabled, recycleEnabled = _b === void 0 ? false : _b, _c = props.horizontal, horizontal = _c === void 0 ? false : _c, getContainerLayout = props.getContainerLayout, canIUseRIC = props.canIUseRIC, _d = props.stickyHeaderIndices, stickyHeaderIndices = _d === void 0 ? [] : _d, _e = props.windowSize, windowSize = _e === void 0 ? common_1.WINDOW_SIZE : _e, _f = props.recycleBufferedCount, recycleBufferedCount = _f === void 0 ? common_1.RECYCLE_BUFFERED_COUNT : _f, _g = props.maxToRenderPerBatch, maxToRenderPerBatch = _g === void 0 ? common_1.MAX_TO_RENDER_PER_BATCH : _g, _h = props.initialNumToRender, initialNumToRender = _h === void 0 ? common_1.INITIAL_NUM_TO_RENDER : _h, _j = props.onEndReachedThreshold, onEndReachedThreshold = _j === void 0 ? common_1.ON_END_REACHED_THRESHOLD : _j; | ||
this.id = id; | ||
@@ -35,2 +35,3 @@ this._horizontal = !!horizontal; | ||
this.stickyHeaderIndices = stickyHeaderIndices; | ||
this._canIUseRIC = canIUseRIC; | ||
} | ||
@@ -61,2 +62,9 @@ Object.defineProperty(BaseLayout.prototype, "initialNumToRender", { | ||
}); | ||
Object.defineProperty(BaseLayout.prototype, "canIUseRIC", { | ||
get: function () { | ||
return this._canIUseRIC; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
BaseLayout.prototype.updateReservedIndices = function () { | ||
@@ -63,0 +71,0 @@ var indices = new Set([].concat(this.persistanceIndices, this.stickyHeaderIndices)); |
@@ -62,3 +62,2 @@ "use strict"; | ||
__extends(ListDimensions, _super); | ||
// private _dataChangeTriggerOnEndReachedTimer: any; | ||
function ListDimensions(props) { | ||
@@ -303,3 +302,4 @@ var _this = _super.call(this, __assign(__assign({}, props), { isIntervalTreeItems: true })) || this; | ||
isListItem: true, | ||
isInitialItem: false | ||
isInitialItem: false, | ||
canIUseRIC: this.canIUseRIC | ||
}); | ||
@@ -386,3 +386,4 @@ this.setKeyMeta(key, meta); | ||
isListItem: true, | ||
isInitialItem: isInitialItem | ||
isInitialItem: isInitialItem, | ||
canIUseRIC: this.canIUseRIC | ||
}); | ||
@@ -389,0 +390,0 @@ if (typeof this._getItemLayout === 'function') { |
@@ -26,2 +26,3 @@ import BaseDimensions from './BaseDimensions'; | ||
readonly _ownerId: string; | ||
readonly _canIUseRIC?: boolean; | ||
@@ -39,2 +40,3 @@ constructor(props: { | ||
isInitialItem?: boolean; | ||
canIUseRIC?: boolean; | ||
}) { | ||
@@ -48,2 +50,3 @@ super(props); | ||
isListItem, | ||
canIUseRIC, | ||
isInitialItem = false, | ||
@@ -62,2 +65,4 @@ } = props; | ||
this._canIUseRIC = canIUseRIC; | ||
// this.addStateListener = this.addStateListener.bind(this); | ||
@@ -165,2 +170,3 @@ // this.removeStateListener = this.removeStateListener.bind(this); | ||
defaultValue: value, | ||
canIUseRIC: this._canIUseRIC, | ||
}); | ||
@@ -167,0 +173,0 @@ this._stateEventSubscriptions.set(eventName, helper); |
@@ -15,4 +15,4 @@ import Batchinator from '@x-oasis/batchinator'; | ||
private _callbackId: number; | ||
private _setupCallbackMs: number; | ||
private _callbackStartMinMs: number; | ||
readonly _canIUseRIC: boolean; | ||
@@ -25,2 +25,3 @@ constructor(props: { | ||
once?: boolean; | ||
canIUseRIC?: boolean; | ||
}) { | ||
@@ -32,2 +33,3 @@ const { | ||
defaultValue = false, | ||
canIUseRIC = true, | ||
once, | ||
@@ -57,2 +59,5 @@ } = props; | ||
} | ||
// ric in RN can not be triggered. https://github.com/facebook/react-native/issues/28602 | ||
this._canIUseRIC = canIUseRIC; | ||
} | ||
@@ -135,7 +140,11 @@ | ||
cancelIdleCallbackPolyfill(callbackId: number) { | ||
// @ts-ignore | ||
if (typeof cancelIdleCallback === 'function') { | ||
if (this._canIUseRIC) { | ||
// @ts-ignore | ||
cancelIdleCallback(callbackId); | ||
if (typeof cancelIdleCallback === 'function') { | ||
// @ts-ignore | ||
cancelIdleCallback(callbackId); | ||
} | ||
} | ||
this._callbackId = null; | ||
} | ||
@@ -164,3 +173,2 @@ | ||
this.cancelIdleCallbackPolyfill(this._callbackId); | ||
this._callbackId = null; | ||
} | ||
@@ -179,10 +187,6 @@ if (this._value !== value) { | ||
this.cancelIdleCallbackPolyfill(this._callbackId); | ||
this._callbackId = null; | ||
} | ||
this._setupCallbackMs = now; | ||
this._callbackStartMinMs = now; | ||
// @ts-ignore | ||
this._callbackId = requestIdleCallback(() => { | ||
const handler = (() => { | ||
if (now < this._callbackStartMinMs) return; | ||
@@ -198,3 +202,8 @@ if (this._value !== value) { | ||
this._value = value; | ||
}); | ||
}).bind(this); | ||
this._callbackId = this._canIUseRIC | ||
? // @ts-ignore | ||
requestIdleCallback(handler) | ||
: handler(); | ||
} | ||
@@ -201,0 +210,0 @@ } |
@@ -65,2 +65,3 @@ import Batchinator from '@x-oasis/batchinator'; | ||
owner: this, | ||
canIUseRIC: this.canIUseRIC, | ||
}) | ||
@@ -67,0 +68,0 @@ ); |
@@ -116,4 +116,2 @@ import noop from '@x-oasis/noop'; | ||
// private _dataChangeTriggerOnEndReachedTimer: any; | ||
constructor(props: ListDimensionsProps<ItemT>) { | ||
@@ -401,2 +399,3 @@ super({ | ||
isInitialItem: false, | ||
canIUseRIC: this.canIUseRIC, | ||
}); | ||
@@ -499,2 +498,3 @@ this.setKeyMeta(key, meta); | ||
isInitialItem, | ||
canIUseRIC: this.canIUseRIC, | ||
}); | ||
@@ -501,0 +501,0 @@ |
@@ -644,2 +644,3 @@ import Batchinator from '@x-oasis/batchinator'; | ||
ignoredToPerBatch, | ||
canIUseRIC: this.canIUseRIC, | ||
}); | ||
@@ -646,0 +647,0 @@ this.setDimension(key, dimensions); |
@@ -52,2 +52,3 @@ import BaseDimensions from './BaseDimensions'; | ||
separatorLength: 0, | ||
canIUseRIC: this.canIUseRIC, | ||
layout: { x: 0, y: 0, height: 0, width: 0 }, | ||
@@ -54,0 +55,0 @@ }); |
@@ -27,2 +27,5 @@ import BaseDimensions from '../BaseDimensions'; | ||
horizontal?: boolean; | ||
canIUseRIC?: boolean; | ||
onUpdateItemLayout?: Function; | ||
@@ -87,2 +90,4 @@ onUpdateIntervalTree?: Function; | ||
dispatchMetricsThreshold?: number; | ||
canIUseRIC?: boolean; | ||
} & BaseDimensionsProps & | ||
@@ -122,2 +127,3 @@ OnEndReachedHelperProps; | ||
indexKeys: Array<string>; | ||
canIUseRIC?: boolean; | ||
} & BaseDimensionsProps; | ||
@@ -127,2 +133,3 @@ | ||
id: string; | ||
canIUseRIC?: boolean; | ||
onRender?: Function; | ||
@@ -129,0 +136,0 @@ horizontal?: boolean; |
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
1921232
109
24254