react-native-onyx 1.0.59 → 1.0.61

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.
@@ -983,7 +983,6 @@ function broadcastUpdate(key, value, hasChanged, method) {
983
983
  }
984
984
 
985
985
  /**
986
- * @private
987
986
  * @param {String} key
988
987
  * @returns {Boolean}
989
988
  */
@@ -1490,7 +1489,8 @@ const Onyx = {
1490
1489
  isSafeEvictionKey,
1491
1490
  METHOD,
1492
1491
  setMemoryOnlyKeys,
1493
- tryGetCachedValue
1492
+ tryGetCachedValue,
1493
+ hasPendingMergeForKey
1494
1494
  };
1495
1495
 
1496
1496
  /**
@@ -2460,7 +2460,18 @@ function getDisplayName(component) {
2460
2460
  const key = _Str__WEBPACK_IMPORTED_MODULE_3__.result(mapping.key, props);
2461
2461
  const value = _Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].tryGetCachedValue(key, mapping);
2462
2462
 
2463
- if (value !== undefined) {
2463
+ /**
2464
+ * If we have a pending merge for a key it could mean that data is being set via Onyx.merge() and someone expects a component to have this data immediately.
2465
+ *
2466
+ * @example
2467
+ *
2468
+ * Onyx.merge('report_123', value);
2469
+ * Navigation.navigate(route); // Where "route" expects the "value" to be available immediately once rendered.
2470
+ *
2471
+ * In reality, Onyx.merge() will only update the subscriber after all merges have been batched and the previous value is retrieved via a get() (returns a promise).
2472
+ * So, we won't use the cache optimization here as it will lead us to arbitrarily defer various actions in the application code.
2473
+ */
2474
+ if (value !== undefined && !_Onyx__WEBPACK_IMPORTED_MODULE_4__["default"].hasPendingMergeForKey(key)) {
2464
2475
  // eslint-disable-next-line no-param-reassign
2465
2476
  resultObj[propertyName] = value;
2466
2477
  }