mobx 6.16.0 → 6.16.1
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/CHANGELOG.md +8 -0
- package/dist/mobx.cjs.development.js +27 -7
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +27 -7
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +27 -7
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +27 -7
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/package.json +2 -4
- package/src/types/computedannotation.ts +30 -13
package/dist/mobx.esm.js
CHANGED
|
@@ -942,24 +942,44 @@ function decorate_20223_$3(get, context) {
|
|
|
942
942
|
var ann = this;
|
|
943
943
|
var key = context.name,
|
|
944
944
|
addInitializer = context.addInitializer;
|
|
945
|
+
var computedValues;
|
|
945
946
|
// Defer ComputedValue creation until first access — avoids allocating
|
|
946
947
|
// ComputedValues for getters that are never read on a given instance.
|
|
947
948
|
// The factory is materialised by ObservableObjectAdministration on demand.
|
|
949
|
+
function createComputedValue(target, adm) {
|
|
950
|
+
var options = _extends({}, ann.options_, {
|
|
951
|
+
get: get,
|
|
952
|
+
context: target
|
|
953
|
+
});
|
|
954
|
+
options.name || (options.name = process.env.NODE_ENV !== "production" ? adm.name_ + "." + key.toString() : "ObservableObject." + key.toString());
|
|
955
|
+
return new ComputedValue(options);
|
|
956
|
+
}
|
|
948
957
|
addInitializer(function () {
|
|
949
958
|
var _adm$lazyComputedKeys;
|
|
950
959
|
var adm = asObservableObject(this)[$mobx];
|
|
951
960
|
var target = this;
|
|
961
|
+
var observable = adm.values_.get(key);
|
|
962
|
+
if (observable instanceof ComputedValue && observable.derivation !== get) {
|
|
963
|
+
adm.values_["delete"](key);
|
|
964
|
+
}
|
|
952
965
|
((_adm$lazyComputedKeys = adm.lazyComputedKeys_) != null ? _adm$lazyComputedKeys : adm.lazyComputedKeys_ = new Map()).set(key, function () {
|
|
953
|
-
|
|
954
|
-
get: get,
|
|
955
|
-
context: target
|
|
956
|
-
});
|
|
957
|
-
options.name || (options.name = process.env.NODE_ENV !== "production" ? adm.name_ + "." + key.toString() : "ObservableObject." + key.toString());
|
|
958
|
-
return new ComputedValue(options);
|
|
966
|
+
return createComputedValue(target, adm);
|
|
959
967
|
});
|
|
960
968
|
});
|
|
961
969
|
return function () {
|
|
962
|
-
|
|
970
|
+
var adm = this[$mobx];
|
|
971
|
+
var observable = adm.values_.get(key);
|
|
972
|
+
if (observable instanceof ComputedValue && observable.derivation !== get) {
|
|
973
|
+
var _computedValues;
|
|
974
|
+
var computed = (_computedValues = computedValues) == null ? void 0 : _computedValues.get(this);
|
|
975
|
+
if (!computed) {
|
|
976
|
+
var _computedValues2;
|
|
977
|
+
computed = createComputedValue(this, adm);
|
|
978
|
+
((_computedValues2 = computedValues) != null ? _computedValues2 : computedValues = new WeakMap()).set(this, computed);
|
|
979
|
+
}
|
|
980
|
+
return computed.get();
|
|
981
|
+
}
|
|
982
|
+
return adm.getObservablePropValue_(key);
|
|
963
983
|
};
|
|
964
984
|
}
|
|
965
985
|
function assertComputedDescriptor(adm, _ref, key, _ref2) {
|