diff --git a/API-INTERNAL.md b/API-INTERNAL.md
index 0dc8b5d84..d8665de66 100644
--- a/API-INTERNAL.md
+++ b/API-INTERNAL.md
@@ -43,6 +43,11 @@ The resulting collection will only contain items that are returned by the select
get()
Get some data from the store
+tupleGet()
+This helper exists to map an array of Onyx keys such as ['report_', 'conciergeReportID']
+to the values for those keys (correctly typed) such as [OnyxCollection<Report>, OnyxEntry<string>]
+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.
+
storeKeyBySubscriptions(subscriptionID, key)
Stores a subscription ID associated with a given key.
@@ -241,6 +246,15 @@ The resulting collection will only contain items that are returned by the select
## get()
Get some data from the store
+**Kind**: global function
+
+
+## tupleGet()
+This helper exists to map an array of Onyx keys such as `['report_', 'conciergeReportID']`
+to the values for those keys (correctly typed) such as `[OnyxCollection, OnyxEntry]`
+
+Note: just using `.map`, you'd end up with `Array|OnyxEntry>`, which is not what we want. This preserves the order of the keys provided.
+
**Kind**: global function
diff --git a/README.md b/README.md
index f82919919..67c7b5590 100644
--- a/README.md
+++ b/README.md
@@ -256,6 +256,21 @@ DO NOT use more than one `withOnyx` component at a time. It adds overhead and pr
It's also beneficial to use a [selector](https://github.com/Expensify/react-native-onyx/blob/main/API.md#connectmapping--number) with the mapping in case you need to grab a single item in a collection (like a single report action).
+### useOnyx()'s `canBeMissing` option
+
+You must pass the `canBeMissing` configuration flag to `useOnyx` if you want the hook to log an alert when data is missing from Onyx store. Regarding usage in `Expensify/App` repo, if the component calling this is the one loading the data by calling an action, then you should set this to `true`. If the component calling this does not load the data then you should set it to `false`, which means that if the data is not there, it will log an alert, as it means we are using data that no one loaded and that's most probably a bug.
+
+```javascript
+const Component = ({reportID}) => {
+ // This hook will log an alert (via `Logger.logAlert()`) if `report` is `undefined`.
+ const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: false});
+
+ // rest of the component's code.
+};
+
+export default Component;
+```
+
## Collections
Collections allow keys with similar value types to be subscribed together by subscribing to the collection key. To define one, it must be included in the `ONYXKEYS.COLLECTION` object and it must be suffixed with an underscore. Member keys should use a unique identifier or index after the collection key prefix (e.g. `report_42`).
diff --git a/lib/Logger.ts b/lib/Logger.ts
index a1fff8332..922b1dd0b 100644
--- a/lib/Logger.ts
+++ b/lib/Logger.ts
@@ -1,6 +1,9 @@
+type Parameters = string | Record | Array> | Error;
+
type LogData = {
message: string;
level: 'alert' | 'info' | 'hmmm';
+ parameters?: Parameters;
};
type LoggerCallback = (data: LogData) => void;
@@ -17,22 +20,22 @@ function registerLogger(callback: LoggerCallback) {
/**
* Send an alert message to the logger
*/
-function logAlert(message: string) {
- logger({message: `[Onyx] ${message}`, level: 'alert'});
+function logAlert(message: string, parameters?: Parameters) {
+ logger({message: `[Onyx] ${message}`, level: 'alert', parameters});
}
/**
* Send an info message to the logger
*/
-function logInfo(message: string) {
- logger({message: `[Onyx] ${message}`, level: 'info'});
+function logInfo(message: string, parameters?: Parameters) {
+ logger({message: `[Onyx] ${message}`, level: 'info', parameters});
}
/**
* Send an hmmm message to the logger
*/
-function logHmmm(message: string) {
- logger({message: `[Onyx] ${message}`, level: 'hmmm'});
+function logHmmm(message: string, parameters?: Parameters) {
+ logger({message: `[Onyx] ${message}`, level: 'hmmm', parameters});
}
export {registerLogger, logInfo, logAlert, logHmmm};
diff --git a/lib/OnyxUtils.ts b/lib/OnyxUtils.ts
index de1c4eada..30cf1a703 100644
--- a/lib/OnyxUtils.ts
+++ b/lib/OnyxUtils.ts
@@ -390,7 +390,7 @@ function multiGet(keys: CollectionKeyBase[]): Promise