react-native-onyx 2.0.84 → 2.0.86
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/metrics.js +0 -5
- package/dist/useOnyx.js +10 -2
- package/package.json +3 -2
- package/lib/index.ts +0 -51
package/dist/metrics.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const PerformanceProxy_1 = __importDefault(require("./dependencies/PerformanceProxy"));
|
|
7
|
-
const decoratedAliases = new Set();
|
|
8
7
|
/**
|
|
9
8
|
* Capture a measurement between the start mark and now
|
|
10
9
|
*/
|
|
@@ -22,10 +21,6 @@ function isPromiseLike(value) {
|
|
|
22
21
|
* Wraps a function with metrics capturing logic
|
|
23
22
|
*/
|
|
24
23
|
function decorateWithMetrics(func, alias = func.name) {
|
|
25
|
-
if (decoratedAliases.has(alias)) {
|
|
26
|
-
throw new Error(`"${alias}" is already decorated`);
|
|
27
|
-
}
|
|
28
|
-
decoratedAliases.add(alias);
|
|
29
24
|
function decorated(...args) {
|
|
30
25
|
const mark = PerformanceProxy_1.default.mark(alias, { detail: { args, alias } });
|
|
31
26
|
const originalReturnValue = func(...args);
|
package/dist/useOnyx.js
CHANGED
|
@@ -31,8 +31,10 @@ const react_1 = require("react");
|
|
|
31
31
|
const OnyxCache_1 = __importStar(require("./OnyxCache"));
|
|
32
32
|
const OnyxConnectionManager_1 = __importDefault(require("./OnyxConnectionManager"));
|
|
33
33
|
const OnyxUtils_1 = __importDefault(require("./OnyxUtils"));
|
|
34
|
+
const GlobalSettings = __importStar(require("./GlobalSettings"));
|
|
34
35
|
const useLiveRef_1 = __importDefault(require("./useLiveRef"));
|
|
35
36
|
const usePrevious_1 = __importDefault(require("./usePrevious"));
|
|
37
|
+
const metrics_1 = __importDefault(require("./metrics"));
|
|
36
38
|
/**
|
|
37
39
|
* Gets the cached value from the Onyx cache. If the key is a collection key, it will return all the values in the collection.
|
|
38
40
|
* It is a fork of `tryGetCachedValue` from `OnyxUtils` caused by different selector logic in `useOnyx`. It should be unified in the future, when `withOnyx` is removed.
|
|
@@ -86,7 +88,7 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
86
88
|
// Indicates if it's the first Onyx connection of this hook or not, as we don't want certain use cases
|
|
87
89
|
// in `getSnapshot()` to be satisfied several times.
|
|
88
90
|
const isFirstConnectionRef = (0, react_1.useRef)(true);
|
|
89
|
-
// Indicates if the hook is connecting to
|
|
91
|
+
// Indicates if the hook is connecting to an Onyx key.
|
|
90
92
|
const isConnectingRef = (0, react_1.useRef)(false);
|
|
91
93
|
// Stores the `onStoreChange()` function, which can be used to trigger a `getSnapshot()` update when desired.
|
|
92
94
|
const onStoreChangeFnRef = (0, react_1.useRef)(null);
|
|
@@ -227,10 +229,16 @@ function useOnyx(key, options, dependencies = []) {
|
|
|
227
229
|
onStoreChangeFnRef.current = null;
|
|
228
230
|
};
|
|
229
231
|
}, [key, options === null || options === void 0 ? void 0 : options.initWithStoredValues, options === null || options === void 0 ? void 0 : options.reuseConnection, checkEvictableKey]);
|
|
232
|
+
const getSnapshotDecorated = (0, react_1.useMemo)(() => {
|
|
233
|
+
if (!GlobalSettings.isPerformanceMetricsEnabled()) {
|
|
234
|
+
return getSnapshot;
|
|
235
|
+
}
|
|
236
|
+
return (0, metrics_1.default)(getSnapshot, 'useOnyx.getSnapshot');
|
|
237
|
+
}, [getSnapshot]);
|
|
230
238
|
(0, react_1.useEffect)(() => {
|
|
231
239
|
checkEvictableKey();
|
|
232
240
|
}, [checkEvictableKey]);
|
|
233
|
-
const result = (0, react_1.useSyncExternalStore)(subscribe,
|
|
241
|
+
const result = (0, react_1.useSyncExternalStore)(subscribe, getSnapshotDecorated);
|
|
234
242
|
return result;
|
|
235
243
|
}
|
|
236
244
|
exports.default = useOnyx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-onyx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.86",
|
|
4
4
|
"author": "Expensify, Inc.",
|
|
5
5
|
"homepage": "https://expensify.com",
|
|
6
6
|
"description": "State management for React Native",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"README.md",
|
|
26
26
|
"LICENSE.md"
|
|
27
27
|
],
|
|
28
|
-
"main": "
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
29
30
|
"scripts": {
|
|
30
31
|
"lint": "eslint .",
|
|
31
32
|
"typecheck": "tsc --noEmit",
|
package/lib/index.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type {ConnectOptions, OnyxUpdate} from './Onyx';
|
|
2
|
-
import Onyx from './Onyx';
|
|
3
|
-
import type {
|
|
4
|
-
CustomTypeOptions,
|
|
5
|
-
KeyValueMapping,
|
|
6
|
-
NullishDeep,
|
|
7
|
-
OnyxCollection,
|
|
8
|
-
OnyxEntry,
|
|
9
|
-
OnyxKey,
|
|
10
|
-
OnyxValue,
|
|
11
|
-
Selector,
|
|
12
|
-
OnyxInputValue,
|
|
13
|
-
OnyxCollectionInputValue,
|
|
14
|
-
OnyxInput,
|
|
15
|
-
OnyxSetInput,
|
|
16
|
-
OnyxMultiSetInput,
|
|
17
|
-
OnyxMergeInput,
|
|
18
|
-
OnyxMergeCollectionInput,
|
|
19
|
-
} from './types';
|
|
20
|
-
import type {FetchStatus, ResultMetadata, UseOnyxResult} from './useOnyx';
|
|
21
|
-
import type {Connection} from './OnyxConnectionManager';
|
|
22
|
-
import useOnyx from './useOnyx';
|
|
23
|
-
import withOnyx from './withOnyx';
|
|
24
|
-
import type {WithOnyxState} from './withOnyx/types';
|
|
25
|
-
|
|
26
|
-
export default Onyx;
|
|
27
|
-
export {useOnyx, withOnyx};
|
|
28
|
-
export type {
|
|
29
|
-
ConnectOptions,
|
|
30
|
-
CustomTypeOptions,
|
|
31
|
-
FetchStatus,
|
|
32
|
-
KeyValueMapping,
|
|
33
|
-
NullishDeep,
|
|
34
|
-
OnyxCollection,
|
|
35
|
-
OnyxEntry,
|
|
36
|
-
OnyxKey,
|
|
37
|
-
OnyxInputValue,
|
|
38
|
-
OnyxCollectionInputValue,
|
|
39
|
-
OnyxInput,
|
|
40
|
-
OnyxSetInput,
|
|
41
|
-
OnyxMultiSetInput,
|
|
42
|
-
OnyxMergeInput,
|
|
43
|
-
OnyxMergeCollectionInput,
|
|
44
|
-
OnyxUpdate,
|
|
45
|
-
OnyxValue,
|
|
46
|
-
ResultMetadata,
|
|
47
|
-
Selector,
|
|
48
|
-
UseOnyxResult,
|
|
49
|
-
WithOnyxState,
|
|
50
|
-
Connection,
|
|
51
|
-
};
|