@tamagui/use-store 2.0.0-rc.8 → 2.0.0
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/cjs/comparators.cjs +18 -14
- package/dist/cjs/comparators.native.js +21 -17
- package/dist/cjs/comparators.native.js.map +1 -1
- package/dist/cjs/configureUseStore.cjs +12 -10
- package/dist/cjs/configureUseStore.native.js +12 -10
- package/dist/cjs/configureUseStore.native.js.map +1 -1
- package/dist/cjs/constants.cjs +17 -15
- package/dist/cjs/constants.native.js +17 -15
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/decorators.cjs +14 -11
- package/dist/cjs/decorators.native.js +14 -11
- package/dist/cjs/decorators.native.js.map +1 -1
- package/dist/cjs/helpers.cjs +28 -21
- package/dist/cjs/helpers.native.js +29 -23
- package/dist/cjs/helpers.native.js.map +1 -1
- package/dist/cjs/index.cjs +13 -11
- package/dist/cjs/index.native.js +30 -19
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interfaces.cjs +7 -5
- package/dist/cjs/interfaces.native.js +7 -5
- package/dist/cjs/interfaces.native.js.map +1 -1
- package/dist/cjs/observe.cjs +105 -59
- package/dist/cjs/observe.native.js +159 -111
- package/dist/cjs/observe.native.js.map +1 -1
- package/dist/cjs/useStore.cjs +271 -194
- package/dist/cjs/useStore.native.js +438 -374
- package/dist/cjs/useStore.native.js.map +1 -1
- package/dist/cjs/useStoreDebug.cjs +42 -31
- package/dist/cjs/useStoreDebug.native.js +42 -36
- package/dist/cjs/useStoreDebug.native.js.map +1 -1
- package/dist/esm/comparators.mjs +6 -4
- package/dist/esm/comparators.mjs.map +1 -1
- package/dist/esm/comparators.native.js +9 -7
- package/dist/esm/comparators.native.js.map +1 -1
- package/dist/esm/constants.mjs +5 -5
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +5 -5
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/decorators.mjs +2 -1
- package/dist/esm/decorators.mjs.map +1 -1
- package/dist/esm/decorators.native.js +2 -1
- package/dist/esm/decorators.native.js.map +1 -1
- package/dist/esm/helpers.mjs +16 -11
- package/dist/esm/helpers.mjs.map +1 -1
- package/dist/esm/helpers.native.js +17 -13
- package/dist/esm/helpers.native.js.map +1 -1
- package/dist/esm/index.js +8 -12
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.native.js +17 -8
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/observe.mjs +77 -33
- package/dist/esm/observe.mjs.map +1 -1
- package/dist/esm/observe.native.js +128 -82
- package/dist/esm/observe.native.js.map +1 -1
- package/dist/esm/useStore.mjs +241 -166
- package/dist/esm/useStore.mjs.map +1 -1
- package/dist/esm/useStore.native.js +408 -346
- package/dist/esm/useStore.native.js.map +1 -1
- package/dist/esm/useStoreDebug.mjs +18 -9
- package/dist/esm/useStoreDebug.mjs.map +1 -1
- package/dist/esm/useStoreDebug.native.js +14 -10
- package/dist/esm/useStoreDebug.native.js.map +1 -1
- package/package.json +6 -9
- package/dist/cjs/comparators.js +0 -33
- package/dist/cjs/comparators.js.map +0 -6
- package/dist/cjs/configureUseStore.js +0 -25
- package/dist/cjs/configureUseStore.js.map +0 -6
- package/dist/cjs/constants.js +0 -25
- package/dist/cjs/constants.js.map +0 -6
- package/dist/cjs/decorators.js +0 -25
- package/dist/cjs/decorators.js.map +0 -6
- package/dist/cjs/helpers.js +0 -50
- package/dist/cjs/helpers.js.map +0 -6
- package/dist/cjs/index.js +0 -34
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/interfaces.js +0 -14
- package/dist/cjs/interfaces.js.map +0 -6
- package/dist/cjs/observe.js +0 -105
- package/dist/cjs/observe.js.map +0 -6
- package/dist/cjs/useStore.js +0 -353
- package/dist/cjs/useStore.js.map +0 -6
- package/dist/cjs/useStoreDebug.js +0 -46
- package/dist/cjs/useStoreDebug.js.map +0 -6
- package/dist/esm/comparators.js +0 -17
- package/dist/esm/comparators.js.map +0 -6
- package/dist/esm/configureUseStore.js +0 -9
- package/dist/esm/configureUseStore.js.map +0 -6
- package/dist/esm/constants.js +0 -9
- package/dist/esm/constants.js.map +0 -6
- package/dist/esm/decorators.js +0 -9
- package/dist/esm/decorators.js.map +0 -6
- package/dist/esm/helpers.js +0 -34
- package/dist/esm/helpers.js.map +0 -6
- package/dist/esm/interfaces.js +0 -1
- package/dist/esm/interfaces.js.map +0 -6
- package/dist/esm/observe.js +0 -84
- package/dist/esm/observe.js.map +0 -6
- package/dist/esm/useStore.js +0 -340
- package/dist/esm/useStore.js.map +0 -6
- package/dist/esm/useStoreDebug.js +0 -22
- package/dist/esm/useStoreDebug.js.map +0 -6
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,21 +5,23 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
23
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
-
value:
|
|
24
|
+
value: true
|
|
23
25
|
}), mod);
|
|
24
26
|
var index_exports = {};
|
|
25
27
|
__export(index_exports, {
|
|
@@ -36,19 +38,28 @@ var import_constants = require("./constants.native.js");
|
|
|
36
38
|
__reExport(index_exports, require("./comparators.native.js"), module.exports);
|
|
37
39
|
__reExport(index_exports, require("./decorators.native.js"), module.exports);
|
|
38
40
|
function _class_call_check(instance, Constructor) {
|
|
39
|
-
if (!(instance instanceof Constructor))
|
|
41
|
+
if (!(instance instanceof Constructor)) {
|
|
42
|
+
throw new TypeError("Cannot call a class as a function");
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
45
|
function _define_property(obj, key, value) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (key in obj) {
|
|
47
|
+
Object.defineProperty(obj, key, {
|
|
48
|
+
value,
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
obj[key] = value;
|
|
55
|
+
}
|
|
56
|
+
return obj;
|
|
48
57
|
}
|
|
49
58
|
var Store = function Store2(props) {
|
|
50
59
|
"use strict";
|
|
51
60
|
|
|
52
|
-
_class_call_check(this, Store2)
|
|
61
|
+
_class_call_check(this, Store2);
|
|
62
|
+
_define_property(this, "props", void 0);
|
|
63
|
+
this.props = props;
|
|
53
64
|
};
|
|
54
65
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","Store","UNWRAP_PROXY","import_constants","configureUseStore","import_configureUseStore","module","exports","__reExport","require","_class_call_check","instance","Constructor","TypeError"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","Store","UNWRAP_PROXY","import_constants","configureUseStore","import_configureUseStore","module","exports","__reExport","require","_class_call_check","instance","Constructor","TypeError"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAC,gBAAA,CAAAD,YAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAC,wBAAA,CAAAD;AAAA;AAAAE,MAAA,CAAAC,OAAA,GAAAb,YAAc,CAAAK,aAAA;AACdS,UAAA,CAAAT,aAAA,EAAAU,OAAkC,0BAAAH,MAAA,CAAAC,OAAA;AAClC,IAAAF,wBAAc,GAAAI,OAAA,gCAFd;AAGAD,UAAA,CAAAT,aAAA,EAAcU,OAAA,yBAHd,GAAAH,MAAA,CAAAC,OAAA;AAIAC,UAAA,CAAAT,aAA6B,EAAAU,OAAA,yBAAAH,MAAA,CAAAC,OAAA;AAC7B,IAAAJ,gBAAA,GAAAM,OAAc;AACdD,UAAA,CAAAT,aAAA,EAAcU,OAAA,6BANdH,MAAA,CAAAC,OAAA;AASOC,UAAM,CAAAT,aAAyC,EAAAU,OAAA,4BAAAH,MAAA,CAAAC,OAAA;AAAA,SACpDG,iBAAiCA,CAAAC,QAAA,EAAAC,WAAA;EAAd,MAAAD,QAAA,YAAAC,WAAA;IAAe,UAAAC,SAAA;EACpC","ignoreList":[]}
|
package/dist/cjs/interfaces.cjs
CHANGED
|
@@ -3,14 +3,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
10
12
|
return to;
|
|
11
13
|
};
|
|
12
14
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
13
|
-
value:
|
|
15
|
+
value: true
|
|
14
16
|
}), mod);
|
|
15
17
|
var interfaces_exports = {};
|
|
16
18
|
module.exports = __toCommonJS(interfaces_exports);
|
|
@@ -5,14 +5,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
12
14
|
return to;
|
|
13
15
|
};
|
|
14
16
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value:
|
|
17
|
+
value: true
|
|
16
18
|
}), mod);
|
|
17
19
|
var interfaces_exports = {};
|
|
18
20
|
module.exports = __toCommonJS(interfaces_exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","interfaces_exports"],"sources":["../../src/interfaces.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","interfaces_exports"],"sources":["../../src/interfaces.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA","ignoreList":[]}
|
package/dist/cjs/observe.cjs
CHANGED
|
@@ -2,118 +2,164 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var observe_exports = {};
|
|
33
35
|
__export(observe_exports, {
|
|
34
36
|
observe: () => observe,
|
|
35
37
|
useObserve: () => useObserve
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(observe_exports);
|
|
38
|
-
var import_react = __toESM(require("react"), 1)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
var import_react = __toESM(require("react"), 1);
|
|
41
|
+
var import_comparators = require("./comparators.cjs");
|
|
42
|
+
var import_constants = require("./constants.cjs");
|
|
43
|
+
var import_useStore = require("./useStore.cjs");
|
|
42
44
|
const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
|
|
43
|
-
const getStoreLogName = store =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const getStoreLogName = store => {
|
|
46
|
+
const str = store[import_constants.UNWRAP_PROXY] ?? store;
|
|
47
|
+
return `${str.constructor.name}${store.props?.id ? `:${store.props.id}` : ""}`;
|
|
48
|
+
};
|
|
49
|
+
const storeNames = stores.map(getStoreLogName).join(", ");
|
|
50
|
+
const name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
|
|
51
|
+
console.groupCollapsed(name, "color: tomato;");
|
|
52
|
+
console.groupCollapsed("trace >");
|
|
53
|
+
console.trace();
|
|
54
|
+
console.groupEnd();
|
|
55
|
+
console.info(" next", next);
|
|
56
|
+
console.groupEnd();
|
|
47
57
|
} : null;
|
|
48
58
|
function observe(fn) {
|
|
49
|
-
let prev = getObserverValueAndStoresAccessed(fn)
|
|
50
|
-
|
|
59
|
+
let prev = getObserverValueAndStoresAccessed(fn);
|
|
60
|
+
let disposeValue = null;
|
|
51
61
|
const subscribe = () => {
|
|
52
62
|
const stores = [...prev.storeInfos];
|
|
53
63
|
return subscribeToStores(stores, () => {
|
|
54
64
|
disposeValue?.();
|
|
55
65
|
const next = getObserverValueAndStoresAccessed(fn);
|
|
56
|
-
if (typeof next.value
|
|
57
|
-
disposeValue = next.value
|
|
66
|
+
if (typeof next.value === "function") {
|
|
67
|
+
disposeValue = next.value;
|
|
68
|
+
if (process.env.NODE_ENV === "development") {
|
|
69
|
+
logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
|
|
70
|
+
}
|
|
58
71
|
return;
|
|
59
72
|
}
|
|
60
|
-
(0, import_comparators.isEqualSubsetShallow)(prev.storeInfos, next.storeInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value)
|
|
73
|
+
if ((0, import_comparators.isEqualSubsetShallow)(prev.storeInfos, next.storeInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (process.env.NODE_ENV === "development") {
|
|
77
|
+
logUpdate(fn, [...next.storeInfos], prev.value, next.value);
|
|
78
|
+
}
|
|
79
|
+
prev = next;
|
|
80
|
+
dispose();
|
|
81
|
+
dispose = subscribe();
|
|
61
82
|
});
|
|
62
83
|
};
|
|
63
84
|
let dispose = subscribe();
|
|
64
85
|
return {
|
|
65
86
|
dispose: () => {
|
|
66
|
-
dispose()
|
|
87
|
+
dispose();
|
|
88
|
+
disposeValue?.();
|
|
67
89
|
},
|
|
68
90
|
getValue: () => prev.value
|
|
69
91
|
};
|
|
70
92
|
}
|
|
71
93
|
function useObserve(fn) {
|
|
72
|
-
const [state, setState] = import_react.default.useState(() =>
|
|
73
|
-
|
|
94
|
+
const [state, setState] = import_react.default.useState(() => {
|
|
95
|
+
return getObserverValueAndStoresAccessed(fn);
|
|
96
|
+
});
|
|
97
|
+
import_react.default.useEffect(() => {
|
|
74
98
|
let dispose;
|
|
75
99
|
const unsub = subscribeToStores([...state.storeInfos], () => {
|
|
76
100
|
dispose?.();
|
|
77
|
-
const next = getObserverValueAndStoresAccessed(fn)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (typeof next.value
|
|
81
|
-
process.env.NODE_ENV === "development"
|
|
101
|
+
const next = getObserverValueAndStoresAccessed(fn);
|
|
102
|
+
const nextStoreInfos = [...next.storeInfos];
|
|
103
|
+
const prevStoreInfos = [...state.storeInfos];
|
|
104
|
+
if (typeof next.value === "function") {
|
|
105
|
+
if (process.env.NODE_ENV === "development") {
|
|
106
|
+
logUpdate(fn, nextStoreInfos, "(fn)", "(fn)");
|
|
107
|
+
}
|
|
108
|
+
dispose = next.value;
|
|
82
109
|
return;
|
|
83
110
|
}
|
|
84
|
-
setState(prev =>
|
|
111
|
+
setState(prev => {
|
|
112
|
+
if ((0, import_comparators.isEqualSubsetShallow)(prevStoreInfos, nextStoreInfos) && (0, import_comparators.isEqualSubsetShallow)(prev.value, next.value)) {
|
|
113
|
+
return prev;
|
|
114
|
+
}
|
|
115
|
+
if (process.env.NODE_ENV === "development") {
|
|
116
|
+
logUpdate(fn, nextStoreInfos, prev.value, next.value);
|
|
117
|
+
}
|
|
118
|
+
return next;
|
|
119
|
+
});
|
|
85
120
|
});
|
|
86
121
|
return () => {
|
|
87
|
-
unsub()
|
|
122
|
+
unsub();
|
|
123
|
+
dispose?.();
|
|
88
124
|
};
|
|
89
|
-
}, [[...state.storeInfos].map(i => i.uid).join(",")])
|
|
125
|
+
}, [[...state.storeInfos].map(i => i.uid).join(",")]);
|
|
126
|
+
return state.value;
|
|
90
127
|
}
|
|
91
128
|
function getObserverValueAndStoresAccessed(selector) {
|
|
92
|
-
const storeInfos = /* @__PURE__ */new Set()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
const storeInfos = /* @__PURE__ */new Set();
|
|
130
|
+
const dispose = (0, import_useStore.trackStoresAccess)(storeInfo => {
|
|
131
|
+
storeInfos.add(storeInfo);
|
|
132
|
+
});
|
|
133
|
+
const value = selector();
|
|
134
|
+
dispose();
|
|
135
|
+
return {
|
|
98
136
|
value,
|
|
99
137
|
storeInfos
|
|
100
138
|
};
|
|
101
139
|
}
|
|
102
140
|
function subscribeToStores(storeInfos, onUpdate) {
|
|
103
141
|
const disposes = [];
|
|
104
|
-
let isUpdating =
|
|
142
|
+
let isUpdating = false;
|
|
105
143
|
const onUpdateDebouncedWithoutTracking = () => {
|
|
106
|
-
|
|
144
|
+
if (isUpdating) return;
|
|
145
|
+
isUpdating = true;
|
|
146
|
+
queueMicrotask(() => {
|
|
107
147
|
try {
|
|
108
|
-
for (const storeInfo of storeInfos)
|
|
148
|
+
for (const storeInfo of storeInfos) {
|
|
149
|
+
storeInfo.disableTracking = true;
|
|
150
|
+
}
|
|
109
151
|
onUpdate();
|
|
110
152
|
} finally {
|
|
111
|
-
isUpdating =
|
|
112
|
-
for (const storeInfo of storeInfos)
|
|
153
|
+
isUpdating = false;
|
|
154
|
+
for (const storeInfo of storeInfos) {
|
|
155
|
+
storeInfo.disableTracking = false;
|
|
156
|
+
}
|
|
113
157
|
}
|
|
114
|
-
})
|
|
158
|
+
});
|
|
115
159
|
};
|
|
116
|
-
for (const storeInfo of storeInfos)
|
|
160
|
+
for (const storeInfo of storeInfos) {
|
|
161
|
+
disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
|
|
162
|
+
}
|
|
117
163
|
return () => {
|
|
118
164
|
disposes.forEach(x => x());
|
|
119
165
|
};
|