@@ -48,17 +48,17 @@ const METHOD = {
4848type OnyxMethod = ValueOf < typeof METHOD > ;
4949
5050// Key/value store of Onyx key and arrays of values to merge
51- const mergeQueue : Record < OnyxKey , Array < OnyxValue < OnyxKey > > > = { } ;
52- const mergeQueuePromise : Record < OnyxKey , Promise < void > > = { } ;
51+ let mergeQueue : Record < OnyxKey , Array < OnyxValue < OnyxKey > > > = { } ;
52+ let 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,15 @@ function updateSnapshots(data: OnyxUpdate[], mergeFn: typeof Onyx.merge): Array<
14311431 return promises ;
14321432}
14331433
1434+ function clearOnyxUtilsInternals ( ) {
1435+ mergeQueue = { } ;
1436+ mergeQueuePromise = { } ;
1437+ callbackToStateMapping = { } ;
1438+ onyxKeyToSubscriptionIDs = new Map ( ) ;
1439+ batchUpdatesQueue = [ ] ;
1440+ lastConnectionCallbackData = new Map ( ) ;
1441+ }
1442+
14341443const OnyxUtils = {
14351444 METHOD ,
14361445 getMergeQueue,
@@ -1480,6 +1489,12 @@ const OnyxUtils = {
14801489 addKeyToRecentlyAccessedIfNeeded,
14811490 reduceCollectionWithSelector,
14821491 updateSnapshots,
1492+ mergeQueue,
1493+ mergeQueuePromise,
1494+ callbackToStateMapping,
1495+ defaultKeyStates,
1496+ batchUpdatesPromise,
1497+ batchUpdatesQueue,
14831498} ;
14841499
14851500GlobalSettings . addGlobalSettingsChangeListener ( ( { enablePerformanceMetrics} ) => {
@@ -1532,3 +1547,4 @@ GlobalSettings.addGlobalSettingsChangeListener(({enablePerformanceMetrics}) => {
15321547
15331548export type { OnyxMethod } ;
15341549export default OnyxUtils ;
1550+ export { clearOnyxUtilsInternals } ;
0 commit comments