mobx 6.0.0 → 6.0.4
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 +141 -117
- package/README.md +6 -3
- package/dist/api/annotation.d.ts +1 -1
- package/dist/api/makeObservable.d.ts +1 -1
- package/dist/core/action.d.ts +1 -1
- package/dist/core/computedvalue.d.ts +1 -1
- package/dist/mobx.cjs.development.js +53 -32
- 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 +5109 -0
- package/dist/mobx.esm.development.js.map +1 -0
- package/dist/mobx.esm.js +51 -32
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +2 -0
- package/dist/mobx.esm.production.min.js.map +1 -0
- package/dist/mobx.umd.development.js +53 -32
- 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/dist/utils/utils.d.ts +1 -1
- package/package.json +72 -138
- package/src/api/annotation.ts +1 -1
- package/src/api/makeObservable.ts +12 -9
- package/src/core/action.ts +4 -4
- package/src/core/computedvalue.ts +1 -1
- package/src/types/observableobject.ts +8 -3
- package/src/types/observablevalue.ts +2 -1
- package/src/utils/global.ts +16 -3
- package/src/utils/utils.ts +2 -2
- package/dist/index.js.flow +0 -591
package/README.md
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
_Simple, scalable state management._
|
|
6
6
|
|
|
7
|
-
[](https://github.com/mobxjs/mobx/discussions)
|
|
8
7
|
[](https://badge.fury.io/js/mobx)
|
|
9
8
|
[](docs/backers-sponsors.md#backers)
|
|
10
9
|
[](docs/backers-sponsors.md#sponsors)
|
|
11
10
|
|
|
11
|
+
[](https://github.com/mobxjs/mobx/discussions)
|
|
12
|
+
[](https://changelogs.xyz/mobx)
|
|
13
|
+
|
|
12
14
|
---
|
|
13
15
|
|
|
14
16
|
MobX is made possible by the generosity of the sponsors below, and many other [individual backers](docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.
|
|
@@ -23,13 +25,14 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
23
25
|
<a href="https://www.canva.com/"><img src="docs/assets/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
|
|
24
26
|
|
|
25
27
|
**🥈Silver sponsors (\$100+ pm):**<br/>
|
|
26
|
-
<a href="https://mantro.net/jobs/warlock"><img src="docs/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
|
|
27
28
|
<a href="https://www.codefirst.co.uk/"><img src="docs/assets/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
|
|
28
29
|
<a href="https://www.dcslsoftware.com/"><img src="docs/assets/dcsl.png" align="center" width="100" title="DCSL Software" alt="DCSL Software"/></a>
|
|
29
30
|
<a href="https://www.bugsnag.com/platforms/react-error-reporting?utm_source=MobX&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term=20190913"><img src="docs/assets/bugsnag.jpg" align="center" width="100" title="Bugsnag" alt="Bugsnag"/></a>
|
|
30
31
|
<a href="https://curology.com/blog/tech"><img src="docs/assets/curology.png" align="center" width="100" title="Curology" alt="Curology"/></a>
|
|
32
|
+
<a href="https://modulz.app/"><img src="docs/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
31
33
|
|
|
32
34
|
**🥉Bronze sponsors (\$500+ total contributions):**<br/>
|
|
35
|
+
<a href="https://mantro.net/jobs/warlock"><img src="docs/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
|
|
33
36
|
<a href="https://www.algolia.com/"><img src="docs/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
34
37
|
<a href="https://talentplot.com/"><img src="docs/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
35
38
|
<a href="https://careers.dazn.com/"><img src="docs/assets/dazn.png" align="center" width="100" title="DAZN" alt="DAZN"></a>
|
|
@@ -163,7 +166,7 @@ Created by [Pavan Podila](https://twitter.com/pavanpodila) and [Michel Weststrat
|
|
|
163
166
|
|
|
164
167
|
- [Introduction to MobX & React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday, _17min_.
|
|
165
168
|
- [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate, _40min_, [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing).
|
|
166
|
-
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://
|
|
169
|
+
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://www.youtube.com/watch?v=ZHxFrbK3VB0&feature=emb_logo) by Michel Weststrate, _30min_.
|
|
167
170
|
- [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby, _42min_.
|
|
168
171
|
- [HolyJS 2019: MobX and the unique symbiosis of predictability and speed](https://www.youtube.com/watch?v=NBYbBbjZeX4&list=PL8sJahqnzh8JJD7xahG5zXkjfM5GOgcPA&index=21&t=0s) by Michel Weststrate, _59min_.
|
|
169
172
|
- [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) by Michel Weststrate, _20min_, [slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx).
|
package/dist/api/annotation.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export declare type Annotation = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare type AnnotationMapEntry = Annotation | true | false;
|
|
6
6
|
export declare type AnnotationsMap<T, AdditionalFields extends PropertyKey> = {
|
|
7
|
-
[P in keyof T]?: AnnotationMapEntry;
|
|
7
|
+
[P in Exclude<keyof T, "toString">]?: AnnotationMapEntry;
|
|
8
8
|
} & Record<AdditionalFields, AnnotationMapEntry>;
|
|
@@ -3,5 +3,5 @@ export declare function makeProperty(adm: ObservableObjectAdministration, owner:
|
|
|
3
3
|
autoBind: boolean): void;
|
|
4
4
|
declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
5
|
export declare function makeObservable<T, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: CreateObservableOptions): T;
|
|
6
|
-
export declare function makeAutoObservable<T extends Object, AdditionalKeys extends PropertyKey = never>(target: T,
|
|
6
|
+
export declare function makeAutoObservable<T extends Object, AdditionalKeys extends PropertyKey = never>(target: T, overrides?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: CreateObservableOptions): T;
|
|
7
7
|
export {};
|
package/dist/core/action.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface IActionRunInfo {
|
|
|
12
12
|
actionId_: number;
|
|
13
13
|
runAsAction_?: boolean;
|
|
14
14
|
}
|
|
15
|
-
export declare function _startAction(actionName: string,
|
|
15
|
+
export declare function _startAction(actionName: string, canRunAsDerivation: boolean, // true for autoAction
|
|
16
16
|
scope: any, args?: IArguments): IActionRunInfo;
|
|
17
17
|
export declare function _endAction(runInfo: IActionRunInfo): void;
|
|
18
18
|
export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
|
|
@@ -72,7 +72,7 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
|
|
|
72
72
|
*
|
|
73
73
|
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
74
74
|
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
75
|
-
* compares based on identity comparison (===), and `
|
|
75
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
76
76
|
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
77
77
|
* don't want to notify observers if it is structurally the same.
|
|
78
78
|
* This is useful for working with vectors, mouse coordinates etc.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var niceErrors = {
|
|
4
6
|
0: "Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",
|
|
5
7
|
1: function _(prop) {
|
|
@@ -85,9 +87,21 @@ function die(error) {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
var mockGlobal = {};
|
|
88
91
|
function getGlobal() {
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
if (typeof window !== "undefined") {
|
|
93
|
+
return window;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (typeof global !== "undefined") {
|
|
97
|
+
return global;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof self !== "undefined") {
|
|
101
|
+
return self;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return mockGlobal;
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
var assign = Object.assign;
|
|
@@ -150,11 +164,11 @@ function isPlainObject(value) {
|
|
|
150
164
|
if (!isObject(value)) return false;
|
|
151
165
|
var proto = Object.getPrototypeOf(value);
|
|
152
166
|
if (proto == null) return true;
|
|
153
|
-
return ((_proto$constructor = proto.constructor)
|
|
167
|
+
return ((_proto$constructor = proto.constructor) == null ? void 0 : _proto$constructor.toString()) === plainObjectString;
|
|
154
168
|
} // https://stackoverflow.com/a/37865170
|
|
155
169
|
|
|
156
170
|
function isGenerator(obj) {
|
|
157
|
-
var constructor = obj
|
|
171
|
+
var constructor = obj == null ? void 0 : obj.constructor;
|
|
158
172
|
if (!constructor) return false;
|
|
159
173
|
if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) return true;
|
|
160
174
|
return false;
|
|
@@ -178,12 +192,12 @@ function addHiddenFinalProp(object, propName, value) {
|
|
|
178
192
|
function assertPropertyConfigurable(object, prop) {
|
|
179
193
|
{
|
|
180
194
|
var descriptor = getDescriptor(object, prop);
|
|
181
|
-
if ((descriptor
|
|
195
|
+
if ((descriptor == null ? void 0 : descriptor.configurable) === false || (descriptor == null ? void 0 : descriptor.writable) === false) die("Cannot make property '" + stringifyKey(prop) + "' observable, it is not configurable and writable in the target object");
|
|
182
196
|
}
|
|
183
197
|
}
|
|
184
|
-
function createInstanceofPredicate(name,
|
|
198
|
+
function createInstanceofPredicate(name, theClass) {
|
|
185
199
|
var propName = "isMobX" + name;
|
|
186
|
-
|
|
200
|
+
theClass.prototype[propName] = true;
|
|
187
201
|
return function (x) {
|
|
188
202
|
return isObject(x) && x[propName] === true;
|
|
189
203
|
};
|
|
@@ -500,7 +514,7 @@ var annotationToEnhancer = (_annotationToEnhancer = {}, _annotationToEnhancer[OB
|
|
|
500
514
|
function getEnhancerFromAnnotation(annotation) {
|
|
501
515
|
var _annotationToEnhancer2;
|
|
502
516
|
|
|
503
|
-
return !annotation ? deepEnhancer : (_annotationToEnhancer2 = annotationToEnhancer[annotation.annotationType_])
|
|
517
|
+
return !annotation ? deepEnhancer : (_annotationToEnhancer2 = annotationToEnhancer[annotation.annotationType_]) != null ? _annotationToEnhancer2 : die(12);
|
|
504
518
|
}
|
|
505
519
|
/**
|
|
506
520
|
* Turns an object, array or function into a reactive structure.
|
|
@@ -544,7 +558,7 @@ var observableFactories = {
|
|
|
544
558
|
object: function object(props, decorators, options) {
|
|
545
559
|
var o = asCreateObservableOptions(options);
|
|
546
560
|
var base = {};
|
|
547
|
-
asObservableObject(base, options
|
|
561
|
+
asObservableObject(base, options == null ? void 0 : options.name, getEnhancerFromOption(o));
|
|
548
562
|
return extendObservable(globalState.useProxies === false || o.proxy === false ? base : createDynamicObservableObject(base), props, decorators, options);
|
|
549
563
|
},
|
|
550
564
|
ref: /*#__PURE__*/createDecorator(OBSERVABLE_REF),
|
|
@@ -598,7 +612,7 @@ var _getDescriptor$config, _getDescriptor;
|
|
|
598
612
|
|
|
599
613
|
var currentActionId = 0;
|
|
600
614
|
var nextActionId = 1;
|
|
601
|
-
var isFunctionNameConfigurable = (_getDescriptor$config = (_getDescriptor = /*#__PURE__*/getDescriptor(function () {}, "name"))
|
|
615
|
+
var isFunctionNameConfigurable = (_getDescriptor$config = (_getDescriptor = /*#__PURE__*/getDescriptor(function () {}, "name")) == null ? void 0 : _getDescriptor.configurable) != null ? _getDescriptor$config : false; // we can safely recycle this object
|
|
602
616
|
|
|
603
617
|
var tmpNameDescriptor = {
|
|
604
618
|
value: "action",
|
|
@@ -641,24 +655,24 @@ function executeAction(actionName, canRunAsDerivation, fn, scope, args) {
|
|
|
641
655
|
_endAction(runInfo);
|
|
642
656
|
}
|
|
643
657
|
}
|
|
644
|
-
function _startAction(actionName,
|
|
658
|
+
function _startAction(actionName, canRunAsDerivation, // true for autoAction
|
|
645
659
|
scope, args) {
|
|
646
660
|
var notifySpy_ = isSpyEnabled() && !!actionName;
|
|
647
661
|
var startTime_ = 0;
|
|
648
662
|
|
|
649
663
|
if ( notifySpy_) {
|
|
650
664
|
startTime_ = Date.now();
|
|
651
|
-
var
|
|
665
|
+
var flattenedArgs = args ? Array.from(args) : EMPTY_ARRAY;
|
|
652
666
|
spyReportStart({
|
|
653
667
|
type: ACTION,
|
|
654
668
|
name: actionName,
|
|
655
669
|
object: scope,
|
|
656
|
-
arguments:
|
|
670
|
+
arguments: flattenedArgs
|
|
657
671
|
});
|
|
658
672
|
}
|
|
659
673
|
|
|
660
674
|
var prevDerivation_ = globalState.trackingDerivation;
|
|
661
|
-
var runAsAction = !
|
|
675
|
+
var runAsAction = !canRunAsDerivation || !prevDerivation_;
|
|
662
676
|
startBatch();
|
|
663
677
|
var prevAllowStateChanges_ = globalState.allowStateChanges; // by default preserve previous allow
|
|
664
678
|
|
|
@@ -1006,7 +1020,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1006
1020
|
*
|
|
1007
1021
|
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1008
1022
|
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1009
|
-
* compares based on identity comparison (===), and `
|
|
1023
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1010
1024
|
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1011
1025
|
* don't want to notify observers if it is structurally the same.
|
|
1012
1026
|
* This is useful for working with vectors, mouse coordinates etc.
|
|
@@ -2339,7 +2353,7 @@ function extendObservable(target, properties, annotations, options) {
|
|
|
2339
2353
|
try {
|
|
2340
2354
|
var descs = getOwnPropertyDescriptors(properties);
|
|
2341
2355
|
getPlainObjectKeys(descs).forEach(function (key) {
|
|
2342
|
-
makeProperty(adm, target, key, descs[key], !annotations ? true : key in annotations ? annotations[key] : true, true, !!(options
|
|
2356
|
+
makeProperty(adm, target, key, descs[key], !annotations ? true : key in annotations ? annotations[key] : true, true, !!(options == null ? void 0 : options.autoBind));
|
|
2343
2357
|
});
|
|
2344
2358
|
} finally {
|
|
2345
2359
|
endBatch();
|
|
@@ -2434,7 +2448,7 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2434
2448
|
}
|
|
2435
2449
|
|
|
2436
2450
|
function next(ret) {
|
|
2437
|
-
if (isFunction(ret
|
|
2451
|
+
if (isFunction(ret == null ? void 0 : ret.then)) {
|
|
2438
2452
|
// an async iterator
|
|
2439
2453
|
ret.then(next, reject);
|
|
2440
2454
|
return;
|
|
@@ -2481,7 +2495,7 @@ function flowResult(result) {
|
|
|
2481
2495
|
return result; // just tricking TypeScript :)
|
|
2482
2496
|
}
|
|
2483
2497
|
function isFlow(fn) {
|
|
2484
|
-
return (fn
|
|
2498
|
+
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
2485
2499
|
}
|
|
2486
2500
|
|
|
2487
2501
|
function interceptReads(thing, propOrHandler, handler) {
|
|
@@ -3025,7 +3039,7 @@ function getInferredAnnotation(desc, defaultAnnotation, autoBind) {
|
|
|
3025
3039
|
|
|
3026
3040
|
if (isFunction(desc.value)) return isGenerator(desc.value) ? flow : isAction(desc.value) ? false : autoBind ? autoAction.bound : autoAction; // if (!desc.configurable || !desc.writable) return false
|
|
3027
3041
|
|
|
3028
|
-
return defaultAnnotation
|
|
3042
|
+
return defaultAnnotation != null ? defaultAnnotation : observable.deep;
|
|
3029
3043
|
}
|
|
3030
3044
|
|
|
3031
3045
|
function getDescriptorInChain(target, prop) {
|
|
@@ -3052,7 +3066,7 @@ autoBind) {
|
|
|
3052
3066
|
var target = adm.target_;
|
|
3053
3067
|
var defaultAnnotation = observable; // ideally grap this from adm's defaultEnahncer instead!
|
|
3054
3068
|
|
|
3055
|
-
var
|
|
3069
|
+
var originAnnotation = annotation;
|
|
3056
3070
|
|
|
3057
3071
|
if (annotation === true) {
|
|
3058
3072
|
annotation = getInferredAnnotation(descriptor, defaultAnnotation, autoBind);
|
|
@@ -3126,20 +3140,20 @@ autoBind) {
|
|
|
3126
3140
|
case OBSERVABLE_STRUCT:
|
|
3127
3141
|
{
|
|
3128
3142
|
if ( isObservableProp(target, key)) die("Cannot decorate '" + key.toString() + "': the property is already decorated as observable.");
|
|
3129
|
-
if ( !("value" in descriptor)) die("Cannot decorate '" + key.toString() + "': observable cannot be used on setter / getter properties."); // if the
|
|
3143
|
+
if ( !("value" in descriptor)) die("Cannot decorate '" + key.toString() + "': observable cannot be used on setter / getter properties."); // if the originAnnotation was true, preferred the adm's default enhancer over the inferred one
|
|
3130
3144
|
|
|
3131
|
-
var enhancer =
|
|
3145
|
+
var enhancer = originAnnotation === true ? adm.defaultEnhancer_ : getEnhancerFromAnnotation(annotation);
|
|
3132
3146
|
adm.addObservableProp_(key, descriptor.value, enhancer);
|
|
3133
3147
|
break;
|
|
3134
3148
|
}
|
|
3135
3149
|
|
|
3136
3150
|
default:
|
|
3137
|
-
die("invalid decorator '" + ((_annotation$annotatio = annotation.annotationType_)
|
|
3151
|
+
die("invalid decorator '" + ((_annotation$annotatio = annotation.annotationType_) != null ? _annotation$annotatio : annotation) + "' for '" + key.toString() + "'");
|
|
3138
3152
|
}
|
|
3139
3153
|
}
|
|
3140
3154
|
function makeObservable(target, annotations, options) {
|
|
3141
|
-
var autoBind = !!(options
|
|
3142
|
-
var adm = asObservableObject(target, options
|
|
3155
|
+
var autoBind = !!(options == null ? void 0 : options.autoBind);
|
|
3156
|
+
var adm = asObservableObject(target, options == null ? void 0 : options.name, getEnhancerFromAnnotation(options == null ? void 0 : options.defaultDecorator));
|
|
3143
3157
|
startBatch();
|
|
3144
3158
|
|
|
3145
3159
|
try {
|
|
@@ -3166,7 +3180,7 @@ function makeObservable(target, annotations, options) {
|
|
|
3166
3180
|
|
|
3167
3181
|
return target;
|
|
3168
3182
|
}
|
|
3169
|
-
function makeAutoObservable(target,
|
|
3183
|
+
function makeAutoObservable(target, overrides, options) {
|
|
3170
3184
|
var proto = Object.getPrototypeOf(target);
|
|
3171
3185
|
var isPlain = proto == null || proto === objectPrototype;
|
|
3172
3186
|
|
|
@@ -3181,7 +3195,7 @@ function makeAutoObservable(target, excludes, options) {
|
|
|
3181
3195
|
// shortcut, reuse inferred annotations for this type from the previous time
|
|
3182
3196
|
annotations = proto[CACHED_ANNOTATIONS];
|
|
3183
3197
|
} else {
|
|
3184
|
-
annotations = _extends({},
|
|
3198
|
+
annotations = _extends({}, overrides);
|
|
3185
3199
|
extractAnnotationsFromObject(target, annotations, options);
|
|
3186
3200
|
|
|
3187
3201
|
if (!isPlain) {
|
|
@@ -3197,8 +3211,8 @@ function makeAutoObservable(target, excludes, options) {
|
|
|
3197
3211
|
function extractAnnotationsFromObject(target, collector, options) {
|
|
3198
3212
|
var _options$defaultDecor;
|
|
3199
3213
|
|
|
3200
|
-
var autoBind = !!(options
|
|
3201
|
-
var defaultAnnotation = (options
|
|
3214
|
+
var autoBind = !!(options == null ? void 0 : options.autoBind);
|
|
3215
|
+
var defaultAnnotation = (options == null ? void 0 : options.deep) === undefined ? (_options$defaultDecor = options == null ? void 0 : options.defaultDecorator) != null ? _options$defaultDecor : observable.deep : (options == null ? void 0 : options.deep) ? observable.deep : observable.ref;
|
|
3202
3216
|
Object.entries(getOwnPropertyDescriptors(target)).forEach(function (_ref) {
|
|
3203
3217
|
var key = _ref[0],
|
|
3204
3218
|
descriptor = _ref[1];
|
|
@@ -3216,7 +3230,7 @@ function extractAnnotationsFromProto(proto, collector, options) {
|
|
|
3216
3230
|
if (prop.get) {
|
|
3217
3231
|
collector[key] = computed;
|
|
3218
3232
|
} else if (isFunction(prop.value)) {
|
|
3219
|
-
collector[key] = isGenerator(prop.value) ? flow : (options
|
|
3233
|
+
collector[key] = isGenerator(prop.value) ? flow : (options == null ? void 0 : options.autoBind) ? autoAction.bound : autoAction;
|
|
3220
3234
|
}
|
|
3221
3235
|
});
|
|
3222
3236
|
}
|
|
@@ -4668,8 +4682,15 @@ function asObservableObject(target, name, defaultEnhancer) {
|
|
|
4668
4682
|
|
|
4669
4683
|
if (hasProp(target, $mobx)) return target[$mobx];
|
|
4670
4684
|
if ( !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
|
|
4671
|
-
|
|
4672
|
-
if (!name)
|
|
4685
|
+
|
|
4686
|
+
if (!name) {
|
|
4687
|
+
if (isPlainObject(target)) {
|
|
4688
|
+
name = "ObservableObject@" + getNextId();
|
|
4689
|
+
} else {
|
|
4690
|
+
name = (target.constructor.name || "ObservableObject") + "@" + getNextId();
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
|
|
4673
4694
|
var adm = new ObservableObjectAdministration(target, new Map(), stringifyKey(name), defaultEnhancer);
|
|
4674
4695
|
addHiddenProp(target, $mobx, adm);
|
|
4675
4696
|
return adm;
|