react-native-onyx 1.0.60 → 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.
- package/dist/web.development.js +14 -3
- package/dist/web.development.js.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/lib/Onyx.js +1 -1
- package/lib/withOnyx.js +12 -1
- package/package.json +1 -1
package/lib/Onyx.js
CHANGED
|
@@ -901,7 +901,6 @@ function broadcastUpdate(key, value, hasChanged, method) {
|
|
|
901
901
|
}
|
|
902
902
|
|
|
903
903
|
/**
|
|
904
|
-
* @private
|
|
905
904
|
* @param {String} key
|
|
906
905
|
* @returns {Boolean}
|
|
907
906
|
*/
|
|
@@ -1409,6 +1408,7 @@ const Onyx = {
|
|
|
1409
1408
|
METHOD,
|
|
1410
1409
|
setMemoryOnlyKeys,
|
|
1411
1410
|
tryGetCachedValue,
|
|
1411
|
+
hasPendingMergeForKey,
|
|
1412
1412
|
};
|
|
1413
1413
|
|
|
1414
1414
|
/**
|
package/lib/withOnyx.js
CHANGED
|
@@ -41,7 +41,18 @@ export default function (mapOnyxToState) {
|
|
|
41
41
|
const key = Str.result(mapping.key, props);
|
|
42
42
|
const value = Onyx.tryGetCachedValue(key, mapping);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* 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.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* Onyx.merge('report_123', value);
|
|
50
|
+
* Navigation.navigate(route); // Where "route" expects the "value" to be available immediately once rendered.
|
|
51
|
+
*
|
|
52
|
+
* 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).
|
|
53
|
+
* So, we won't use the cache optimization here as it will lead us to arbitrarily defer various actions in the application code.
|
|
54
|
+
*/
|
|
55
|
+
if (value !== undefined && !Onyx.hasPendingMergeForKey(key)) {
|
|
45
56
|
// eslint-disable-next-line no-param-reassign
|
|
46
57
|
resultObj[propertyName] = value;
|
|
47
58
|
}
|