@@ -52,13 +52,13 @@ const mergeQueue: Record<OnyxKey, Array<OnyxValue<OnyxKey>>> = {};
5252const mergeQueuePromise : Record < OnyxKey , Promise < void > > = { } ;
5353
5454// Holds a mapping of all the React components that want their state subscribed to a store key
55- const callbackToStateMapping : Record < string , Mapping < OnyxKey > > = { } ;
55+ let callbackToStateMapping : Record < string , Mapping < OnyxKey > > = { } ;
5656
5757// Keeps a copy of the values of the onyx collection keys as a map for faster lookups
5858let onyxCollectionKeySet = new Set < OnyxKey > ( ) ;
5959
6060// Holds a mapping of the connected key to the subscriptionID for faster lookups
61- const onyxKeyToSubscriptionIDs = new Map ( ) ;
61+ let onyxKeyToSubscriptionIDs = new Map ( ) ;
6262
6363// Optional user-provided key value states set when Onyx initializes or clears
6464let defaultKeyStates : Record < OnyxKey , OnyxValue < OnyxKey > > = { } ;
@@ -67,7 +67,7 @@ let batchUpdatesPromise: Promise<void> | null = null;
6767let batchUpdatesQueue : Array < ( ) => void > = [ ] ;
6868
6969// Used for comparison with a new update to avoid invoking the Onyx.connect callback with the same data.
70- const lastConnectionCallbackData = new Map < number , OnyxValue < OnyxKey > > ( ) ;
70+ let lastConnectionCallbackData = new Map < number , OnyxValue < OnyxKey > > ( ) ;
7171
7272let snapshotKey : OnyxKey | null = null ;
7373
@@ -1431,6 +1431,12 @@ function updateSnapshots(data: OnyxUpdate[], mergeFn: typeof Onyx.merge): Array<
14311431 return promises ;
14321432}
14331433
1434+ function clearInternals ( ) : void {
1435+ callbackToStateMapping = { } ;
1436+ onyxKeyToSubscriptionIDs = new Map ( ) ;
1437+ lastConnectionCallbackData = new Map ( ) ;
1438+ }
1439+
14341440const OnyxUtils = {
14351441 METHOD ,
14361442 getMergeQueue,
@@ -1480,6 +1486,7 @@ const OnyxUtils = {
14801486 addKeyToRecentlyAccessedIfNeeded,
14811487 reduceCollectionWithSelector,
14821488 updateSnapshots,
1489+ clearInternals,
14831490} ;
14841491
14851492GlobalSettings . addGlobalSettingsChangeListener ( ( { enablePerformanceMetrics} ) => {
0 commit comments