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