1+ import memoizeOne from "memoize-one" ;
2+
13import { store } from "@/lib/store" ;
24import type {
35 CallbackRef ,
@@ -7,7 +9,7 @@ import type {
79 InputRef ,
810} from "@/lib/types/model/callback" ;
911import { getInputValues } from "@/lib/actions/helpers/getInputValues" ;
10- import { getValue } from "@/lib/utils/getValue" ;
12+ import { getValue , type PropertyPath } from "@/lib/utils/getValue" ;
1113import { invokeCallbacks } from "@/lib/actions/helpers/invokeCallbacks" ;
1214import type { ContributionState } from "@/lib" ;
1315
@@ -16,14 +18,13 @@ import type { ContributionState } from "@/lib";
1618 */
1719export interface PropertyRef extends ContribRef , CallbackRef , InputRef {
1820 /** The property name as path. */
19- propertyPath : string [ ] ;
21+ propertyPath : PropertyPath ;
2022}
2123
2224export function handleHostStoreChange < S extends object = object > (
2325 currState : S ,
2426 prevState : S ,
2527) {
26- console . log ( "Aaaaaaaarghhh!" ) ;
2728 const { contributionsRecord } = store . getState ( ) ;
2829 const callbackRequests = getCallbackRequests (
2930 contributionsRecord ,
@@ -56,9 +57,9 @@ function getCallbackRequests<S extends object = object>(
5657 return callbackRequest ;
5758}
5859
59- // TODO: memoize this function,
60- // its return value should stay constant.
61- function getHostStorePropertyRefs ( ) : PropertyRef [ ] {
60+ const getHostStorePropertyRefs = memoizeOne ( _getHostStorePropertyRefs ) ;
61+
62+ function _getHostStorePropertyRefs ( ) : PropertyRef [ ] {
6263 const { contributionsRecord } = store . getState ( ) ;
6364 const propertyRefs : PropertyRef [ ] = [ ] ;
6465 Object . getOwnPropertyNames ( contributionsRecord ) . forEach ( ( contribPoint ) => {
@@ -85,7 +86,7 @@ function getHostStorePropertyRefs(): PropertyRef[] {
8586}
8687
8788function hasPropertyChanged < S extends object = object > (
88- propertyPath : string [ ] ,
89+ propertyPath : PropertyPath ,
8990 currState : S ,
9091 prevState : S ,
9192) : boolean {
0 commit comments