react-native-onyx 2.0.91 → 2.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,6 +69,15 @@ declare function batchUpdates(updates: () => void): Promise<void>;
69
69
  /** Get some data from the store */
70
70
  declare function get<TKey extends OnyxKey, TValue extends OnyxValue<TKey>>(key: TKey): Promise<TValue>;
71
71
  declare function multiGet<TKey extends OnyxKey>(keys: CollectionKeyBase[]): Promise<Map<OnyxKey, OnyxValue<TKey>>>;
72
+ /**
73
+ * This helper exists to map an array of Onyx keys such as `['report_', 'conciergeReportID']`
74
+ * to the values for those keys (correctly typed) such as `[OnyxCollection<Report>, OnyxEntry<string>]`
75
+ *
76
+ * Note: just using .map, you'd end up with `Array<OnyxCollection<Report>|OnyxEntry<string>>`, which is not what we want. This preserves the order of the keys provided.
77
+ */
78
+ declare function tupleGet<Keys extends readonly OnyxKey[]>(keys: Keys): Promise<{
79
+ [Index in keyof Keys]: OnyxValue<Keys[Index]>;
80
+ }>;
72
81
  /** Returns current key names stored in persisted storage */
73
82
  declare function getAllKeys(): Promise<Set<OnyxKey>>;
74
83
  /**
@@ -281,6 +290,7 @@ declare const OnyxUtils: {
281
290
  initializeWithDefaultKeyStates: typeof initializeWithDefaultKeyStates;
282
291
  getSnapshotKey: typeof getSnapshotKey;
283
292
  multiGet: typeof multiGet;
293
+ tupleGet: typeof tupleGet;
284
294
  isValidNonEmptyCollectionForMerge: typeof isValidNonEmptyCollectionForMerge;
285
295
  doAllCollectionItemsBelongToSameParent: typeof doAllCollectionItemsBelongToSameParent;
286
296
  subscribeToKey: typeof subscribeToKey;
package/dist/OnyxUtils.js CHANGED
@@ -310,6 +310,15 @@ function multiGet(keys) {
310
310
  return dataMap;
311
311
  }));
312
312
  }
313
+ /**
314
+ * This helper exists to map an array of Onyx keys such as `['report_', 'conciergeReportID']`
315
+ * to the values for those keys (correctly typed) such as `[OnyxCollection<Report>, OnyxEntry<string>]`
316
+ *
317
+ * Note: just using .map, you'd end up with `Array<OnyxCollection<Report>|OnyxEntry<string>>`, which is not what we want. This preserves the order of the keys provided.
318
+ */
319
+ function tupleGet(keys) {
320
+ return Promise.all(keys.map((key) => OnyxUtils.get(key)));
321
+ }
313
322
  /**
314
323
  * Stores a subscription ID associated with a given key.
315
324
  *
@@ -1203,6 +1212,7 @@ const OnyxUtils = {
1203
1212
  initializeWithDefaultKeyStates,
1204
1213
  getSnapshotKey,
1205
1214
  multiGet,
1215
+ tupleGet,
1206
1216
  isValidNonEmptyCollectionForMerge,
1207
1217
  doAllCollectionItemsBelongToSameParent,
1208
1218
  subscribeToKey,
@@ -1253,6 +1263,8 @@ GlobalSettings.addGlobalSettingsChangeListener(({ enablePerformanceMetrics }) =>
1253
1263
  // @ts-expect-error Complex type signature
1254
1264
  multiGet = (0, metrics_1.default)(multiGet, 'OnyxUtils.multiGet');
1255
1265
  // @ts-expect-error Reassign
1266
+ tupleGet = (0, metrics_1.default)(tupleGet, 'OnyxUtils.tupleGet');
1267
+ // @ts-expect-error Reassign
1256
1268
  subscribeToKey = (0, metrics_1.default)(subscribeToKey, 'OnyxUtils.subscribeToKey');
1257
1269
  });
1258
1270
  exports.default = OnyxUtils;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import type { ConnectOptions, OnyxUpdate } from './Onyx';
2
2
  import Onyx from './Onyx';
3
3
  import type { CustomTypeOptions, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, Selector, OnyxInputValue, OnyxCollectionInputValue, OnyxInput, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput } from './types';
4
- import type { FetchStatus, ResultMetadata, UseOnyxResult } from './useOnyx';
4
+ import type { FetchStatus, ResultMetadata, UseOnyxResult, UseOnyxOptions } from './useOnyx';
5
5
  import type { Connection } from './OnyxConnectionManager';
6
6
  import useOnyx from './useOnyx';
7
7
  import withOnyx from './withOnyx';
8
8
  import type { WithOnyxState } from './withOnyx/types';
9
9
  export default Onyx;
10
10
  export { useOnyx, withOnyx };
11
- export type { ConnectOptions, CustomTypeOptions, FetchStatus, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxInputValue, OnyxCollectionInputValue, OnyxInput, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, ResultMetadata, Selector, UseOnyxResult, WithOnyxState, Connection, };
11
+ export type { ConnectOptions, CustomTypeOptions, FetchStatus, KeyValueMapping, NullishDeep, OnyxCollection, OnyxEntry, OnyxKey, OnyxInputValue, OnyxCollectionInputValue, OnyxInput, OnyxSetInput, OnyxMultiSetInput, OnyxMergeInput, OnyxMergeCollectionInput, OnyxUpdate, OnyxValue, ResultMetadata, Selector, UseOnyxResult, WithOnyxState, Connection, UseOnyxOptions, };
package/dist/useOnyx.d.ts CHANGED
@@ -49,4 +49,4 @@ type UseOnyxResult<TValue> = [NonNullable<TValue> | undefined, ResultMetadata];
49
49
  declare function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: BaseUseOnyxOptions & UseOnyxInitialValueOption<TReturnValue> & Required<UseOnyxSelectorOption<TKey, TReturnValue>>, dependencies?: DependencyList): UseOnyxResult<TReturnValue>;
50
50
  declare function useOnyx<TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: BaseUseOnyxOptions & UseOnyxInitialValueOption<NoInfer<TReturnValue>>, dependencies?: DependencyList): UseOnyxResult<TReturnValue>;
51
51
  export default useOnyx;
52
- export type { FetchStatus, ResultMetadata, UseOnyxResult, BaseUseOnyxOptions, UseOnyxSelector, UseOnyxSelectorOption, UseOnyxInitialValueOption, UseOnyxOptions };
52
+ export type { FetchStatus, ResultMetadata, UseOnyxResult, UseOnyxOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "2.0.91",
3
+ "version": "2.0.93",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",