jpf-mobx 1.0.120 → 1.0.122
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/index.d.ts +2 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/observable.d.ts +13 -12
- package/dist/observable.js +3 -0
- package/dist/observable.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +28 -13
- package/src/observable.ts +18 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { controls, utilities, attributes, element, event,
|
|
1
|
+
import { controls, utilities, attributes, element, event, observableInterfaces, properties, root, style, types } from "jpf";
|
|
2
2
|
export { controls };
|
|
3
3
|
export { utilities };
|
|
4
4
|
export { attributes };
|
|
5
5
|
export { element };
|
|
6
6
|
export { event };
|
|
7
|
-
export {
|
|
7
|
+
export { observableInterfaces };
|
|
8
8
|
export { properties };
|
|
9
9
|
export { root };
|
|
10
10
|
export { style };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { controls, utilities, attributes, element, event,
|
|
1
|
+
import { controls, utilities, attributes, element, event, observableInterfaces, observableImplementations, properties, root, style, types } from "jpf";
|
|
2
|
+
import { unwrap, isComputed, isObservableValue, isObservableArray, isObservableMap, isObservableSet, computed, observableValue, observableArray, observableMap, observableSet } from "./observable";
|
|
3
|
+
observableImplementations.implementations.unwrap = unwrap;
|
|
4
|
+
observableImplementations.implementations.isComputed = isComputed;
|
|
5
|
+
observableImplementations.implementations.isObservableValue = isObservableValue;
|
|
6
|
+
observableImplementations.implementations.isObservableArray = isObservableArray;
|
|
7
|
+
observableImplementations.implementations.isObservableMap = isObservableMap;
|
|
8
|
+
observableImplementations.implementations.isObservableSet = isObservableSet;
|
|
9
|
+
observableImplementations.implementations.computed = computed;
|
|
10
|
+
observableImplementations.implementations.observableValue = observableValue;
|
|
11
|
+
observableImplementations.implementations.observableArray = observableArray;
|
|
12
|
+
observableImplementations.implementations.observableMap = observableMap;
|
|
13
|
+
observableImplementations.implementations.observableSet = observableSet;
|
|
2
14
|
export { controls };
|
|
3
15
|
export { utilities };
|
|
4
16
|
export { attributes };
|
|
5
17
|
export { element };
|
|
6
18
|
export { event };
|
|
7
|
-
export {
|
|
19
|
+
export { observableInterfaces };
|
|
8
20
|
export { properties };
|
|
9
21
|
export { root };
|
|
10
22
|
export { style };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,SAAS,EACT,UAAU,EACV,OAAO,EACP,KAAK,EACL,oBAAoB,EACpB,yBAAyB,EACzB,UAAU,EACV,IAAI,EACJ,KAAK,EACL,KAAK,EACR,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGpM,yBAAyB,CAAC,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC;AAC1D,yBAAyB,CAAC,eAAe,CAAC,UAAU,GAAG,UAAU,CAAC;AAClE,yBAAyB,CAAC,eAAe,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AAChF,yBAAyB,CAAC,eAAe,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AAChF,yBAAyB,CAAC,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5E,yBAAyB,CAAC,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5E,yBAAyB,CAAC,eAAe,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC9D,yBAAyB,CAAC,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5E,yBAAyB,CAAC,eAAe,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5E,yBAAyB,CAAC,eAAe,CAAC,aAAa,GAAG,aAAa,CAAC;AACxE,yBAAyB,CAAC,eAAe,CAAC,aAAa,GAAG,aAAa,CAAC;AAExE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,cAAc,cAAc,CAAC"}
|
package/dist/observable.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IComputedValueOptions as mobxIComputedValueOptions, CreateObservableOptions as mobxCreateObservableOptions, IObservableMapInitialValues as mobxIObservableMapInitialValues, IObservableSetInitialValues as mobxIObservableSetInitialValues } from "mobx";
|
|
2
|
-
import {
|
|
3
|
-
export declare function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>):
|
|
2
|
+
import { observableInterfaces } from "jpf";
|
|
3
|
+
export declare function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>): observableInterfaces.IComputed<TComputed>;
|
|
4
4
|
export declare function runInAction<T>(fn: () => T): T;
|
|
5
|
-
export declare function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue:
|
|
6
|
-
export declare function observableArray<TItem = any, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray:
|
|
7
|
-
export declare function observableMap<TKey = any, TItem = any>(initialValues?: mobxIObservableMapInitialValues<TKey, TItem>, options?: mobxCreateObservableOptions):
|
|
8
|
-
export declare function observableSet<TItem = any>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions):
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
5
|
+
export declare function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: observableInterfaces.IObservableValue<TValue, TSetter>) => void, options?: mobxCreateObservableOptions): observableInterfaces.IObservableValue<TValue, TSetter>;
|
|
6
|
+
export declare function observableArray<TItem = any, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: observableInterfaces.IObservableArray<TItem, TSetter>) => void, options?: mobxCreateObservableOptions): observableInterfaces.IObservableArray<TItem, TSetter>;
|
|
7
|
+
export declare function observableMap<TKey = any, TItem = any>(initialValues?: mobxIObservableMapInitialValues<TKey, TItem>, options?: mobxCreateObservableOptions): observableInterfaces.IObservableMap<TKey, TItem>;
|
|
8
|
+
export declare function observableSet<TItem = any>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions): observableInterfaces.IObservableSet<TItem>;
|
|
9
|
+
export declare function isComputed<TValue>(value: any): value is observableInterfaces.IComputed<TValue>;
|
|
10
|
+
export declare function isSubscribable<TValue>(value: any): value is observableInterfaces.ISubscribable<TValue>;
|
|
11
|
+
export declare function isObservableValue(value: any): value is observableInterfaces.IObservableValue;
|
|
12
|
+
export declare function isObservableArray(value: any): value is observableInterfaces.IObservableArray;
|
|
13
|
+
export declare function isObservableMap<TKey, TItem>(value: any): value is observableInterfaces.IObservableMap<TKey, TItem>;
|
|
14
|
+
export declare function isObservableSet<TItem>(value: any): value is observableInterfaces.IObservableSet<TItem>;
|
|
15
|
+
export declare function unwrap<TValue>(value: TValue | observableInterfaces.ISubscribable<TValue>): TValue;
|
package/dist/observable.js
CHANGED
|
@@ -79,6 +79,9 @@ export function observableSet(initialValues, options) {
|
|
|
79
79
|
options = { ...defaultOptions, ...options };
|
|
80
80
|
return mobxObservable.set(initialValues, options);
|
|
81
81
|
}
|
|
82
|
+
export function isComputed(value) {
|
|
83
|
+
return mobxIsComputed(value);
|
|
84
|
+
}
|
|
82
85
|
export function isSubscribable(value) {
|
|
83
86
|
return mobxIsComputed(value)
|
|
84
87
|
|| mobxIsObservableValue(value)
|
package/dist/observable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../src/observable.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EAExB,UAAU,IAAI,cAAc,EAE5B,iBAAiB,IAAI,qBAAqB,EAC1C,iBAAiB,IAAI,qBAAqB,EAC1C,eAAe,IAAI,mBAAmB,EACtC,eAAe,IAAI,mBAAmB,EACtC,WAAW,IAAI,eAAe,EAC9B,QAAQ,IAAI,YAAY,EAK3B,MAAM,MAAM,CAAC;AAKd,MAAM,UAAU,QAAQ,CAAY,IAAqB,EAAE,OAA8C;IACrG,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../src/observable.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EAExB,UAAU,IAAI,cAAc,EAE5B,iBAAiB,IAAI,qBAAqB,EAC1C,iBAAiB,IAAI,qBAAqB,EAC1C,eAAe,IAAI,mBAAmB,EACtC,eAAe,IAAI,mBAAmB,EACtC,WAAW,IAAI,eAAe,EAC9B,QAAQ,IAAI,YAAY,EAK3B,MAAM,MAAM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C,CAAC;AAED,MAAM,UAAU,eAAe,CAAc,KAAK;IAC9C,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,eAAe,CAAQ,KAAK;IACxC,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,MAAM,CAAS,KAA0D;IACrF,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAQ,KAAsC,CAAC,GAAG,EAAE,CAAC;IACzD,CAAC;IAED,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,EAAmB,CAAC;IAC1C,CAAC;IAED,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAkB,CAAC;IAC3C,CAAC;IAED,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,GAAG,CAAC,KAAK,CAAkB,CAAC;IAC3C,CAAC;IAED,OAAO,KAAe,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jpf-mobx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.122",
|
|
4
4
|
"description": "Javascript Presentation Foundation with mobx state management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mvvm",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"tscVersion": "tsc -v"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"jpf": "5.0.
|
|
45
|
+
"jpf": "5.0.13",
|
|
46
46
|
"mobx": "6.12.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
controls,
|
|
3
|
-
utilities,
|
|
4
|
-
attributes,
|
|
5
|
-
element,
|
|
6
|
-
event,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import {
|
|
2
|
+
controls,
|
|
3
|
+
utilities,
|
|
4
|
+
attributes,
|
|
5
|
+
element,
|
|
6
|
+
event,
|
|
7
|
+
observableInterfaces,
|
|
8
|
+
observableImplementations,
|
|
9
|
+
properties,
|
|
10
|
+
root,
|
|
11
|
+
style,
|
|
12
|
+
types
|
|
12
13
|
} from "jpf";
|
|
13
14
|
|
|
15
|
+
import { unwrap, isComputed, isObservableValue, isObservableArray, isObservableMap, isObservableSet, computed, observableValue, observableArray, observableMap, observableSet } from "./observable";
|
|
16
|
+
|
|
17
|
+
//Set the mobx implementations for the observable functions
|
|
18
|
+
observableImplementations.implementations.unwrap = unwrap;
|
|
19
|
+
observableImplementations.implementations.isComputed = isComputed;
|
|
20
|
+
observableImplementations.implementations.isObservableValue = isObservableValue;
|
|
21
|
+
observableImplementations.implementations.isObservableArray = isObservableArray;
|
|
22
|
+
observableImplementations.implementations.isObservableMap = isObservableMap;
|
|
23
|
+
observableImplementations.implementations.isObservableSet = isObservableSet;
|
|
24
|
+
observableImplementations.implementations.computed = computed;
|
|
25
|
+
observableImplementations.implementations.observableValue = observableValue;
|
|
26
|
+
observableImplementations.implementations.observableArray = observableArray;
|
|
27
|
+
observableImplementations.implementations.observableMap = observableMap;
|
|
28
|
+
observableImplementations.implementations.observableSet = observableSet;
|
|
29
|
+
|
|
14
30
|
export { controls };
|
|
15
31
|
export { utilities };
|
|
16
32
|
export { attributes };
|
|
17
33
|
export { element };
|
|
18
34
|
export { event };
|
|
19
|
-
export {
|
|
35
|
+
export { observableInterfaces }
|
|
20
36
|
export { properties };
|
|
21
37
|
export { root };
|
|
22
38
|
export { style };
|
|
23
39
|
export { types };
|
|
24
|
-
|
|
25
40
|
export * from "./observable";
|
package/src/observable.ts
CHANGED
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
IReactionPublic as mobxIReactionPublic
|
|
17
17
|
} from "mobx";
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { observableInterfaces } from "jpf";
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
export function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>):
|
|
22
|
+
export function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>): observableInterfaces.IComputed<TComputed> {
|
|
23
23
|
const computed = mobxComputed(func, options);
|
|
24
|
-
const iComputed = computed as any as
|
|
24
|
+
const iComputed = computed as any as observableInterfaces.IComputed<TComputed>;
|
|
25
25
|
|
|
26
26
|
iComputed.subscribe = (effect: (arg: TComputed, prev: TComputed, r: mobxIReactionPublic) => void) => {
|
|
27
27
|
return mobxReaction(
|
|
@@ -41,11 +41,11 @@ export function runInAction<T>(fn: () => T): T {
|
|
|
41
41
|
return mobxRunInAction<T>(fn);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue:
|
|
44
|
+
export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: observableInterfaces.IObservableValue<TValue, TSetter>) => void, options?: mobxCreateObservableOptions): observableInterfaces.IObservableValue<TValue, TSetter> {
|
|
45
45
|
if (options && !options.deep) {
|
|
46
46
|
options.deep = false;
|
|
47
47
|
}
|
|
48
|
-
const observableValue = mobxObservable.box(value || null, options) as any as
|
|
48
|
+
const observableValue = mobxObservable.box(value || null, options) as any as observableInterfaces.IObservableValue<TValue, TSetter>;
|
|
49
49
|
|
|
50
50
|
observableValue.setValue = (newValue: TSetter) => {
|
|
51
51
|
if (newValue === undefined) {
|
|
@@ -79,8 +79,8 @@ export function observableValue<TValue, TSetter = TValue>(value?: TValue | null,
|
|
|
79
79
|
return observableValue;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
export function observableArray<TItem = any, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray:
|
|
83
|
-
const observableArray = mobxObservable.array(initialValues || null, options) as any as
|
|
82
|
+
export function observableArray<TItem = any, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: observableInterfaces.IObservableArray<TItem, TSetter>) => void, options?: mobxCreateObservableOptions): observableInterfaces.IObservableArray<TItem, TSetter> {
|
|
83
|
+
const observableArray = mobxObservable.array(initialValues || null, options) as any as observableInterfaces.IObservableArray<TItem, TSetter>;
|
|
84
84
|
|
|
85
85
|
observableArray.setItems = (newValue: TSetter) => {
|
|
86
86
|
if (newValue === undefined) {
|
|
@@ -111,7 +111,7 @@ export function observableArray<TItem = any, TSetter = Array<TItem>>(initialValu
|
|
|
111
111
|
return observableArray;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export function observableMap<TKey = any, TItem = any>(initialValues?: mobxIObservableMapInitialValues<TKey, TItem>, options?: mobxCreateObservableOptions):
|
|
114
|
+
export function observableMap<TKey = any, TItem = any>(initialValues?: mobxIObservableMapInitialValues<TKey, TItem>, options?: mobxCreateObservableOptions): observableInterfaces.IObservableMap<TKey, TItem> {
|
|
115
115
|
//Add a deep property if the property does not already exist
|
|
116
116
|
var defaultOptions = { deep: false };
|
|
117
117
|
options = { ...defaultOptions, ...options };
|
|
@@ -119,7 +119,7 @@ export function observableMap<TKey = any, TItem = any>(initialValues?: mobxIObse
|
|
|
119
119
|
return mobxObservable.map<TKey, TItem>(initialValues, options);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export function observableSet<TItem = any>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions):
|
|
122
|
+
export function observableSet<TItem = any>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions): observableInterfaces.IObservableSet<TItem> {
|
|
123
123
|
//Add a deep property if the property does not already exist
|
|
124
124
|
var defaultOptions = { deep: false };
|
|
125
125
|
options = { ...defaultOptions, ...options };
|
|
@@ -127,8 +127,11 @@ export function observableSet<TItem = any>(initialValues?: mobxIObservableSetIni
|
|
|
127
127
|
return mobxObservable.set<TItem>(initialValues, options);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
export function isComputed<TValue>(value: any): value is observableInterfaces.IComputed<TValue> {
|
|
131
|
+
return mobxIsComputed(value);
|
|
132
|
+
}
|
|
130
133
|
|
|
131
|
-
export function isSubscribable<TValue>(value: any): value is
|
|
134
|
+
export function isSubscribable<TValue>(value: any): value is observableInterfaces.ISubscribable<TValue> {
|
|
132
135
|
return mobxIsComputed(value)
|
|
133
136
|
|| mobxIsObservableValue(value)
|
|
134
137
|
|| mobxIsObservableArray(value)
|
|
@@ -136,23 +139,23 @@ export function isSubscribable<TValue>(value: any): value is observable.ISubscri
|
|
|
136
139
|
|| mobxIsObservableSet(value);
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
export function isObservableValue(value): value is
|
|
142
|
+
export function isObservableValue(value): value is observableInterfaces.IObservableValue {
|
|
140
143
|
return mobxIsObservableValue(value);
|
|
141
144
|
}
|
|
142
145
|
|
|
143
|
-
export function isObservableArray(value): value is
|
|
146
|
+
export function isObservableArray(value): value is observableInterfaces.IObservableArray {
|
|
144
147
|
return mobxIsObservableArray(value);
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
export function isObservableMap<TKey, TItem>(value): value is
|
|
150
|
+
export function isObservableMap<TKey, TItem>(value): value is observableInterfaces.IObservableMap<TKey, TItem> {
|
|
148
151
|
return mobxIsObservableMap(value);
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
export function isObservableSet<TItem>(value): value is
|
|
154
|
+
export function isObservableSet<TItem>(value): value is observableInterfaces.IObservableSet<TItem> {
|
|
152
155
|
return mobxIsObservableSet(value);
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
export function unwrap<TValue>(value: TValue |
|
|
158
|
+
export function unwrap<TValue>(value: TValue | observableInterfaces.ISubscribable<TValue>): TValue {
|
|
156
159
|
if (mobxIsComputed(value) || mobxIsObservableValue(value)) {
|
|
157
160
|
return (value as mobxIObservableValue<TValue>).get();
|
|
158
161
|
}
|