react-native-onyx 2.0.127 → 2.0.128
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/README.md +2 -9
- package/dist/Onyx.js +1 -1
- package/dist/types.d.ts +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,30 +61,23 @@ The data will then be cached and stored via [`AsyncStorage`](https://github.com/
|
|
|
61
61
|
|
|
62
62
|
### Performance Options for Large Objects
|
|
63
63
|
|
|
64
|
-
For performance-critical scenarios with large objects, `Onyx.set()` accepts optional
|
|
64
|
+
For performance-critical scenarios with large objects, `Onyx.set()` accepts optional flag to skip expensive operations:
|
|
65
65
|
|
|
66
66
|
```javascript
|
|
67
67
|
Onyx.set(ONYXKEYS.LARGE_DATA, computedValue, {
|
|
68
68
|
skipCacheCheck: true, // Skip deep equality check
|
|
69
|
-
skipNullRemoval: true, // Skip null value pruning
|
|
70
69
|
});
|
|
71
70
|
```
|
|
72
71
|
|
|
73
72
|
**Options:**
|
|
74
73
|
- `skipCacheCheck`: Skips the deep equality comparison with the cached value. By default, Onyx compares new values against cached ones to avoid unnecessary updates. For large objects, this comparison can be expensive.
|
|
75
|
-
- `skipNullRemoval`: Skips the removal of `null` values from nested objects. By default, Onyx removes `null` values before storage. Use this when `null` values are meaningful in your data structure.
|
|
76
74
|
|
|
77
75
|
#### When to Use SetOptions
|
|
78
76
|
- **Use `skipCacheCheck: true`** for:
|
|
79
77
|
- Large objects where deep equality checking is expensive
|
|
80
78
|
- Values that you know have changed
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
- Computed values where `null` represents a legitimate result
|
|
84
|
-
- Data structures where `null` has semantic meaning
|
|
85
|
-
- Values that should preserve their exact structure
|
|
86
|
-
|
|
87
|
-
**Note**: These options are recommended only for large objects where performance is critical. Most use cases should use the standard `Onyx.set(key, value)` syntax.
|
|
80
|
+
**Note**: These option is recommended only for large objects where performance is critical. Most use cases should use the standard `Onyx.set(key, value)` syntax.
|
|
88
81
|
|
|
89
82
|
## Merging data
|
|
90
83
|
|
package/dist/Onyx.js
CHANGED
|
@@ -186,7 +186,7 @@ function set(key, value, options) {
|
|
|
186
186
|
OnyxUtils_1.default.logKeyRemoved(OnyxUtils_1.default.METHOD.SET, key);
|
|
187
187
|
return Promise.resolve();
|
|
188
188
|
}
|
|
189
|
-
const valueWithoutNestedNullValues =
|
|
189
|
+
const valueWithoutNestedNullValues = utils_1.default.removeNestedNullValues(value);
|
|
190
190
|
const hasChanged = (options === null || options === void 0 ? void 0 : options.skipCacheCheck) ? true : OnyxCache_1.default.hasValueChanged(key, valueWithoutNestedNullValues);
|
|
191
191
|
OnyxUtils_1.default.logKeyChanged(OnyxUtils_1.default.METHOD.SET, key, value, hasChanged);
|
|
192
192
|
// This approach prioritizes fast UI changes without waiting for data to be stored in device storage.
|
package/dist/types.d.ts
CHANGED
|
@@ -374,8 +374,6 @@ type OnyxUpdate = {
|
|
|
374
374
|
type SetOptions = {
|
|
375
375
|
/** Skip the deep equality check against the cached value. Improves performance for large objects. */
|
|
376
376
|
skipCacheCheck?: boolean;
|
|
377
|
-
/** Skip pruning null values from the object. Improves performance for large objects. */
|
|
378
|
-
skipNullRemoval?: boolean;
|
|
379
377
|
};
|
|
380
378
|
/**
|
|
381
379
|
* Represents the options used in `Onyx.init()` method.
|