@@ -20,8 +20,6 @@ import memoize from "fast-memoize";
2020export interface PropertyRef extends ContribRef , CallbackRef , InputRef {
2121 /** The property. */
2222 property : string ;
23- /** Property ID for memoization */
24- id : string ;
2523}
2624
2725export function handleHostStoreChange ( ) {
@@ -74,29 +72,34 @@ export function getCallbackRequests(
7472 ) ;
7573}
7674
75+ // This is a dummy function created to memoize the _inputValues values
76+ const _getInputValues = ( _inputValues : unknown [ ] ) : unknown [ ] => {
77+ return _inputValues ;
78+ } ;
79+ const memoizedInputValues = memoize ( _getInputValues ) ;
80+
7781const getCallbackRequest = (
7882 propertyRef : PropertyRef ,
7983 lastCallbackInputValues : Record < string , unknown [ ] > | undefined ,
8084 contributionsRecord : Record < string , ContributionState [ ] > ,
8185 hostStore : HostStore ,
8286) => {
83- const contributions = contributionsRecord [ propertyRef . contribPoint ] ;
84- const contribution = contributions [ propertyRef . contribIndex ] ;
85- const callback = contribution . callbacks ! [ propertyRef . callbackIndex ] ;
87+ const contribPoint : string = propertyRef . contribPoint ;
88+ const contribIndex : number = propertyRef . contribIndex ;
89+ const callbackIndex : number = propertyRef . callbackIndex ;
90+ const inputIndex : number = propertyRef . inputIndex ;
91+ const contributions = contributionsRecord [ contribPoint ] ;
92+ const contribution = contributions [ contribIndex ] ;
93+ const callback = contribution . callbacks ! [ callbackIndex ] ;
8694 const _inputValues = getInputValues (
8795 callback . inputs ! ,
8896 contribution ,
8997 hostStore ,
9098 ) ;
9199
92- // This is a dummy function created to memoize the _inputValues values
93- const _getInputValues = ( _inputValues : unknown [ ] ) : unknown [ ] => {
94- return _inputValues ;
95- } ;
96- const memoizedInputValues = memoize ( _getInputValues ) ;
97100 const inputValues = memoizedInputValues ( _inputValues ) ;
98101
99- const propRefId = propertyRef . id ;
102+ const propRefId = ` ${ contribPoint } - ${ contribIndex } - ${ callbackIndex } - ${ inputIndex } ` ;
100103 if ( lastCallbackInputValues ) {
101104 const lastInputValues = lastCallbackInputValues [ propRefId ] ;
102105 if ( lastInputValues && shallowEqualArrays ( lastInputValues , inputValues ) ) {
@@ -142,7 +145,6 @@ function getHostStorePropertyRefs(): PropertyRef[] {
142145 callbackIndex,
143146 inputIndex,
144147 property : formatObjPath ( input . property ) ,
145- id : `${ contribPoint } -${ contribIndex } -${ callbackIndex } -${ inputIndex } ` ,
146148 } ) ;
147149 }
148150 } ) ,
0 commit comments