react-bindings
Advanced tools
Comparing version 1.6.2 to 1.6.3
@@ -18,6 +18,2 @@ import type { Binding } from '../types/binding'; | ||
private onChangeListeners_?; | ||
/** The last changeCount from onChangeListeners_ that was used to generate lastChangeListenersArray_ */ | ||
private lastChangeListenersArrayChangeCount_; | ||
/** The immutable array version of onChangeListeners_ */ | ||
private lastChangeListenersArray_; | ||
/** | ||
@@ -63,4 +59,4 @@ * A flag indicating whether or not this binding was modified. This is initially `false` when the binding is created and set to `true` | ||
readonly addChangeListener: (listener: ChangeListener) => () => void; | ||
readonly triggerChangeListeners: () => void; | ||
readonly triggerChangeListeners: () => number; | ||
} | ||
//# sourceMappingURL=binding-impl.d.ts.map |
@@ -10,3 +10,2 @@ "use strict"; | ||
const DoubleLinkedList_1 = require("./DoubleLinkedList"); | ||
const emptyListenersList = Object.freeze([]); | ||
/** The standard implementation of a read-write binding */ | ||
@@ -25,6 +24,2 @@ class BindingImpl { | ||
this.changeUid_ = this.uid; // Using the binding's uid as the initial change ID for convenience | ||
/** The last changeCount from onChangeListeners_ that was used to generate lastChangeListenersArray_ */ | ||
this.lastChangeListenersArrayChangeCount_ = 0; | ||
/** The immutable array version of onChangeListeners_ */ | ||
this.lastChangeListenersArray_ = emptyListenersList; | ||
/** | ||
@@ -80,7 +75,7 @@ * A flag indicating whether or not this binding was modified. This is initially `false` when the binding is created and set to `true` | ||
this.changeUid_ = (0, uid_1.makeUID)(); | ||
this.triggerChangeListeners(); | ||
const numListeners = this.triggerChangeListeners(); | ||
(_e = (_d = (0, stats_handler_1.getStatsHandler)()).trackBindingDidSetRaw) === null || _e === void 0 ? void 0 : _e.call(_d, { | ||
binding: this, | ||
durationMSec: performance.now() - startMSec, | ||
numListeners: this.lastChangeListenersArray_.length | ||
numListeners | ||
}); | ||
@@ -167,13 +162,10 @@ }; | ||
this.triggerChangeListeners = () => { | ||
var _a, _b, _c, _d; | ||
const newCount = (_b = (_a = this.onChangeListeners_) === null || _a === void 0 ? void 0 : _a.getChangeCount()) !== null && _b !== void 0 ? _b : 0; | ||
if (this.lastChangeListenersArrayChangeCount_ !== newCount) { | ||
this.lastChangeListenersArrayChangeCount_ = newCount; | ||
// Using onChangeListeners.toArray() to clone in case onChangeListeners itself changes while handling these callbacks | ||
this.lastChangeListenersArray_ = (_d = (_c = this.onChangeListeners_) === null || _c === void 0 ? void 0 : _c.toArray()) !== null && _d !== void 0 ? _d : emptyListenersList; | ||
if (this.onChangeListeners_ === undefined) { | ||
return 0; | ||
} | ||
const listeners = this.lastChangeListenersArray_; | ||
const listeners = this.onChangeListeners_.toArray(); | ||
for (const listener of listeners) { | ||
listener(); | ||
} | ||
return listeners === null || listeners === void 0 ? void 0 : listeners.length; | ||
}; | ||
@@ -180,0 +172,0 @@ const theInitialValue = initializer(false); |
export declare class DoubleLinkedList<ItemT> { | ||
private changeCount; | ||
/** This is set to `undefined` on any list mutations and rebuilt when `toArray` is called if needed */ | ||
private allValues; | ||
private firstNode; | ||
@@ -7,3 +8,2 @@ private lastNode; | ||
constructor(...items: ItemT[]); | ||
readonly getChangeCount: () => number; | ||
readonly getLength: () => number; | ||
@@ -16,3 +16,3 @@ readonly isEmpty: () => boolean; | ||
readonly getTail: () => Readonly<DoubleLinkedListNode<ItemT>> | undefined; | ||
readonly toArray: () => ItemT[]; | ||
readonly toArray: () => Readonly<ItemT[]>; | ||
readonly remove: (node: DoubleLinkedListNode<ItemT>) => boolean; | ||
@@ -22,3 +22,3 @@ } | ||
list: DoubleLinkedList<ItemT> | undefined; | ||
value: ItemT; | ||
readonly value: ItemT; | ||
previousNode?: DoubleLinkedListNode<ItemT> | undefined; | ||
@@ -25,0 +25,0 @@ nextNode?: DoubleLinkedListNode<ItemT> | undefined; |
@@ -6,5 +6,3 @@ "use strict"; | ||
constructor(...items) { | ||
this.changeCount = 0; | ||
this.length = 0; | ||
this.getChangeCount = () => this.changeCount; | ||
this.getLength = () => this.length; | ||
@@ -23,3 +21,3 @@ this.isEmpty = () => this.firstNode === undefined; | ||
} | ||
this.changeCount += 1; | ||
this.allValues = undefined; | ||
this.length += 1; | ||
@@ -39,3 +37,3 @@ return newNode; | ||
} | ||
this.changeCount += 1; | ||
this.allValues = undefined; | ||
this.length += 1; | ||
@@ -52,2 +50,5 @@ return newNode; | ||
this.toArray = () => { | ||
if (this.allValues !== undefined) { | ||
return this.allValues; | ||
} | ||
const output = []; | ||
@@ -59,2 +60,3 @@ let cursor = this.firstNode; | ||
} | ||
this.allValues = Object.freeze(output); | ||
return output; | ||
@@ -94,3 +96,3 @@ }; | ||
node.list = undefined; | ||
this.changeCount += 1; | ||
this.allValues = undefined; | ||
this.length -= 1; | ||
@@ -97,0 +99,0 @@ return true; |
{ | ||
"name": "react-bindings", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "Data bindings for React", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
"dependencies": { | ||
"client-run-queue": "^1.1.9", | ||
"client-run-queue": "^1.1.10", | ||
"is-promise": "^4.0.0", | ||
@@ -43,11 +43,11 @@ "lodash": "^4.17.21" | ||
"@testing-library/react": "^13.3.0", | ||
"@types/jest": "^28.1.6", | ||
"@types/lodash": "4.14.182", | ||
"@types/jest": "^28.1.7", | ||
"@types/lodash": "4.14.184", | ||
"@types/react": "18.0.17", | ||
"@types/react-dom": "18.0.6", | ||
"@typescript-eslint/eslint-plugin": "^5.33.0", | ||
"@typescript-eslint/parser": "^5.33.0", | ||
"eslint": "8.21.0", | ||
"@typescript-eslint/eslint-plugin": "^5.34.0", | ||
"@typescript-eslint/parser": "^5.34.0", | ||
"eslint": "8.22.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-import-resolver-typescript": "^3.4.0", | ||
"eslint-import-resolver-typescript": "^3.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
@@ -67,3 +67,3 @@ "eslint-plugin-prefer-arrow": "^1.2.3", | ||
"trash-cli": "5.0.0", | ||
"ts-jest": "^28.0.7", | ||
"ts-jest": "^28.0.8", | ||
"typedoc": "^0.23.10", | ||
@@ -70,0 +70,0 @@ "typescript": "4.7.4" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
201688
2412
Updatedclient-run-queue@^1.1.10