react-native-onyx 1.0.22 → 1.0.24
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/API.md +0 -1
- package/dist/web.development.js +4 -14
- 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 -4
- package/lib/storage/WebStorage.js +2 -9
- package/lib/storage/index.native.js +2 -7
- package/package.json +1 -1
package/lib/Onyx.js
CHANGED
|
@@ -1024,8 +1024,6 @@ function update(data) {
|
|
|
1024
1024
|
* @param {Boolean} [options.captureMetrics] Enables Onyx benchmarking and exposes the get/print/reset functions
|
|
1025
1025
|
* @param {Boolean} [options.shouldSyncMultipleInstances] Auto synchronize storage events between multiple instances
|
|
1026
1026
|
* of Onyx running in different tabs/windows. Defaults to true for platforms that support local storage (web/desktop)
|
|
1027
|
-
* @param {String[]} [option.keysToDisableSyncEvents=[]] Contains keys for which
|
|
1028
|
-
* we want to disable sync event across tabs.
|
|
1029
1027
|
* @param {Boolean} [options.debugSetState] Enables debugging setState() calls to connected components.
|
|
1030
1028
|
* @example
|
|
1031
1029
|
* Onyx.init({
|
|
@@ -1042,7 +1040,6 @@ function init({
|
|
|
1042
1040
|
maxCachedKeysCount = 1000,
|
|
1043
1041
|
captureMetrics = false,
|
|
1044
1042
|
shouldSyncMultipleInstances = Boolean(global.localStorage),
|
|
1045
|
-
keysToDisableSyncEvents = [],
|
|
1046
1043
|
debugSetState = false,
|
|
1047
1044
|
} = {}) {
|
|
1048
1045
|
if (captureMetrics) {
|
|
@@ -1076,7 +1073,7 @@ function init({
|
|
|
1076
1073
|
.then(deferredInitTask.resolve);
|
|
1077
1074
|
|
|
1078
1075
|
if (shouldSyncMultipleInstances && _.isFunction(Storage.keepInstancesSync)) {
|
|
1079
|
-
Storage.keepInstancesSync(
|
|
1076
|
+
Storage.keepInstancesSync((key, value) => {
|
|
1080
1077
|
cache.set(key, value);
|
|
1081
1078
|
keyChanged(key, value);
|
|
1082
1079
|
});
|
|
@@ -16,12 +16,9 @@ const webStorage = {
|
|
|
16
16
|
...Storage,
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {String[]} keysToDisableSyncEvents
|
|
21
|
-
* Storage synchronization mechanism keeping all opened tabs in sync
|
|
22
|
-
* @param {function(key: String, data: *)} onStorageKeyChanged
|
|
19
|
+
* @param {Function} onStorageKeyChanged Storage synchronization mechanism keeping all opened tabs in sync
|
|
23
20
|
*/
|
|
24
|
-
keepInstancesSync(
|
|
21
|
+
keepInstancesSync(onStorageKeyChanged) {
|
|
25
22
|
// Override set, remove and clear to raise storage events that we intercept in other tabs
|
|
26
23
|
this.setItem = (key, value) => Storage.setItem(key, value)
|
|
27
24
|
.then(() => raiseStorageSyncEvent(key));
|
|
@@ -43,10 +40,6 @@ const webStorage = {
|
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
const onyxKey = event.newValue;
|
|
46
|
-
if (_.contains(keysToDisableSyncEvents, onyxKey)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
43
|
Storage.getItem(onyxKey)
|
|
51
44
|
.then(value => onStorageKeyChanged(onyxKey, value));
|
|
52
45
|
});
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NativeStorage from './NativeStorage';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
default: () => require('./WebStorage').default,
|
|
5
|
-
native: () => require('./NativeStorage').default,
|
|
6
|
-
})();
|
|
7
|
-
|
|
8
|
-
export default Storage;
|
|
3
|
+
export default NativeStorage;
|