jpf-mobx 1.0.158 → 1.0.159
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 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/observable.d.ts +20 -0
- package/dist/observable.js +14 -14
- package/dist/observable.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -2
- package/src/observable.ts +25 -16
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { controls, utilities, attributes, element, event, properties, root, style, css
|
|
1
|
+
import { controls, utilities, attributes, element, event, properties, root, style, css } from "jpf";
|
|
2
|
+
import * as observable from "./observable";
|
|
2
3
|
export { controls };
|
|
3
4
|
export { utilities };
|
|
4
5
|
export { attributes };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { controls, utilities, attributes, element, event, properties, root, style, css
|
|
1
|
+
import { controls, utilities, attributes, element, event, properties, root, style, css } from "jpf";
|
|
2
|
+
import * as observable from "./observable";
|
|
2
3
|
export { controls };
|
|
3
4
|
export { utilities };
|
|
4
5
|
export { attributes };
|
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,UAAU,EACV,IAAI,EACJ,KAAK,EACL,GAAG,
|
|
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,UAAU,EACV,IAAI,EACJ,KAAK,EACL,GAAG,EACN,MAAM,KAAK,CAAC;AAEb,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAG3C,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,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,GAAG,EAAE,CAAC;AAGf,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/observable.d.ts
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
+
import { IComputedValueOptions as mobxIComputedValueOptions, CreateObservableOptions as mobxCreateObservableOptions, IObservableSetInitialValues as mobxIObservableSetInitialValues, IMapEntries as mobxIMapEntries } from "mobx";
|
|
2
|
+
import { observable as jpfObservable } from "jpf";
|
|
1
3
|
export declare function runInAction<T>(fn: () => T): T;
|
|
4
|
+
export type IComputed<TValue> = jpfObservable.IComputed<TValue>;
|
|
5
|
+
export type IDisposer = jpfObservable.IDisposer;
|
|
6
|
+
export type IObservableArray<TItem = any, TSetter = TItem[]> = jpfObservable.IObservableArray<TItem, TSetter>;
|
|
7
|
+
export type IObservableMap<TKey = unknown, TItem = unknown> = jpfObservable.IObservableMap<TKey, TItem>;
|
|
8
|
+
export type IObservableSet<TItem = unknown> = jpfObservable.IObservableSet<TItem>;
|
|
9
|
+
export type IObservableValue<TValue, TSetter = TValue> = jpfObservable.IObservableValue<TValue, TSetter>;
|
|
10
|
+
export type ISubscribable<TValue> = jpfObservable.ISubscribable<TValue>;
|
|
11
|
+
export declare function unwrap<TValue>(value: TValue | jpfObservable.ISubscribable<TValue>): TValue;
|
|
12
|
+
export declare function isComputed<TValue>(value: unknown): value is jpfObservable.IComputed<TValue>;
|
|
13
|
+
export declare function isObservableValue(value: any): value is jpfObservable.IObservableValue;
|
|
14
|
+
export declare function isObservableArray(value: any): value is jpfObservable.IObservableArray;
|
|
15
|
+
export declare function isObservableMap<TKey, TItem>(value: any): value is jpfObservable.IObservableMap<TKey, TItem>;
|
|
16
|
+
export declare function isObservableSet<TItem>(value: any): value is jpfObservable.IObservableSet<TItem>;
|
|
17
|
+
export declare function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>): jpfObservable.IComputed<TComputed>;
|
|
18
|
+
export declare function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: jpfObservable.IObservableValue<TValue, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableValue<TValue, TSetter>;
|
|
19
|
+
export declare function observableArray<TItem = unknown, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: jpfObservable.IObservableArray<TItem, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableArray<TItem, TSetter>;
|
|
20
|
+
export declare function observableMap<TKey = unknown, TItem = unknown>(initialValues?: mobxIMapEntries<TKey, TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableMap<TKey, TItem>;
|
|
21
|
+
export declare function observableSet<TItem = unknown>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableSet<TItem>;
|
package/dist/observable.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { observable as mobxObservable, computed as mobxComputed, isComputed as mobxIsComputed, isBoxedObservable as mobxIsObservableValue, isObservableArray as mobxIsObservableArray, isObservableMap as mobxIsObservableMap, isObservableSet as mobxIsObservableSet, runInAction as mobxRunInAction, reaction as mobxReaction } from "mobx";
|
|
2
2
|
import { observable as jpfObservable } from "jpf";
|
|
3
|
-
export function runInAction(fn) {
|
|
4
|
-
return mobxRunInAction(fn);
|
|
5
|
-
}
|
|
6
3
|
function setDefaultOptions(target, source) {
|
|
7
4
|
if (source) {
|
|
8
5
|
target = target || {};
|
|
@@ -14,7 +11,10 @@ function setDefaultOptions(target, source) {
|
|
|
14
11
|
}
|
|
15
12
|
return target;
|
|
16
13
|
}
|
|
17
|
-
function
|
|
14
|
+
export function runInAction(fn) {
|
|
15
|
+
return mobxRunInAction(fn);
|
|
16
|
+
}
|
|
17
|
+
export function unwrap(value) {
|
|
18
18
|
if (mobxIsComputed(value) || mobxIsObservableValue(value)) {
|
|
19
19
|
return value.get();
|
|
20
20
|
}
|
|
@@ -29,22 +29,22 @@ function unwrap(value) {
|
|
|
29
29
|
}
|
|
30
30
|
return value;
|
|
31
31
|
}
|
|
32
|
-
function isComputed(value) {
|
|
32
|
+
export function isComputed(value) {
|
|
33
33
|
return mobxIsComputed(value);
|
|
34
34
|
}
|
|
35
|
-
function isObservableValue(value) {
|
|
35
|
+
export function isObservableValue(value) {
|
|
36
36
|
return mobxIsObservableValue(value);
|
|
37
37
|
}
|
|
38
|
-
function isObservableArray(value) {
|
|
38
|
+
export function isObservableArray(value) {
|
|
39
39
|
return mobxIsObservableArray(value);
|
|
40
40
|
}
|
|
41
|
-
function isObservableMap(value) {
|
|
41
|
+
export function isObservableMap(value) {
|
|
42
42
|
return mobxIsObservableMap(value);
|
|
43
43
|
}
|
|
44
|
-
function isObservableSet(value) {
|
|
44
|
+
export function isObservableSet(value) {
|
|
45
45
|
return mobxIsObservableSet(value);
|
|
46
46
|
}
|
|
47
|
-
function computed(func, options) {
|
|
47
|
+
export function computed(func, options) {
|
|
48
48
|
const computed = mobxComputed(func, options);
|
|
49
49
|
const iComputed = computed;
|
|
50
50
|
iComputed.subscribe = (effect) => {
|
|
@@ -56,7 +56,7 @@ function computed(func, options) {
|
|
|
56
56
|
};
|
|
57
57
|
return iComputed;
|
|
58
58
|
}
|
|
59
|
-
function observableValue(value, setter, options) {
|
|
59
|
+
export function observableValue(value, setter, options) {
|
|
60
60
|
setDefaultOptions(options, { deep: false });
|
|
61
61
|
const observableValue = mobxObservable.box(value || null, options);
|
|
62
62
|
observableValue.setValue = (newValue) => {
|
|
@@ -95,7 +95,7 @@ function observableValue(value, setter, options) {
|
|
|
95
95
|
};
|
|
96
96
|
return observableValue;
|
|
97
97
|
}
|
|
98
|
-
function observableArray(initialValues, setter, options) {
|
|
98
|
+
export function observableArray(initialValues, setter, options) {
|
|
99
99
|
options = setDefaultOptions(options, { deep: false });
|
|
100
100
|
const observableArray = mobxObservable.array(initialValues || null, options);
|
|
101
101
|
observableArray.setItems = (newValue) => {
|
|
@@ -130,12 +130,12 @@ function observableArray(initialValues, setter, options) {
|
|
|
130
130
|
};
|
|
131
131
|
return observableArray;
|
|
132
132
|
}
|
|
133
|
-
function observableMap(initialValues, options) {
|
|
133
|
+
export function observableMap(initialValues, options) {
|
|
134
134
|
const defaultOptions = { deep: false };
|
|
135
135
|
options = { ...defaultOptions, ...options };
|
|
136
136
|
return mobxObservable.map(initialValues, options);
|
|
137
137
|
}
|
|
138
|
-
function observableSet(initialValues, options) {
|
|
138
|
+
export function observableSet(initialValues, options) {
|
|
139
139
|
const defaultOptions = { deep: false };
|
|
140
140
|
options = { ...defaultOptions, ...options };
|
|
141
141
|
return mobxObservable.set(initialValues, options);
|
package/dist/observable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../src/observable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../src/observable.ts"],"names":[],"mappings":"AACA,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;AAEd,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,KAAK,CAAC;AAElD,SAAS,iBAAiB,CAAW,MAAgB,EAAE,MAAgB;IAC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CAAC;IACvC,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;IAE5C,OAAO,cAAc,CAAC,GAAG,CAAc,aAAa,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,aAAa,CAAkB,aAAsD,EAAE,OAAqC;IAExI,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACvC,OAAO,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,OAAO,EAAE,CAAC;IAE5C,OAAO,cAAc,CAAC,GAAG,CAAQ,aAAa,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAGD,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;AAG5C,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;AAC3B,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;AACnC,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AACjD,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AACjD,UAAU,CAAC,eAAe,GAAG,eAAe,CAAC;AAC7C,UAAU,CAAC,eAAe,GAAG,eAAe,CAAC;AAC7C,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;AAC9B,UAAU,CAAC,eAAe,GAAG,eAAe,CAAC;AAC7C,UAAU,CAAC,eAAe,GAAG,eAAe,CAAC;AAC7C,UAAU,CAAC,aAAa,GAAG,aAAa,CAAC;AACzC,UAAU,CAAC,aAAa,GAAG,aAAa,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
properties,
|
|
8
8
|
root,
|
|
9
9
|
style,
|
|
10
|
-
css
|
|
11
|
-
observable
|
|
10
|
+
css
|
|
12
11
|
} from "jpf";
|
|
13
12
|
|
|
13
|
+
import * as observable from "./observable";
|
|
14
14
|
|
|
15
|
+
//Export the Jpf modules
|
|
15
16
|
export { controls };
|
|
16
17
|
export { utilities };
|
|
17
18
|
export { attributes };
|
|
@@ -21,4 +22,6 @@ export { properties };
|
|
|
21
22
|
export { root };
|
|
22
23
|
export { style };
|
|
23
24
|
export { css };
|
|
25
|
+
|
|
26
|
+
//Export the Jpf-Mobx observable module
|
|
24
27
|
export { observable };
|
package/src/observable.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import {
|
|
2
3
|
observable as mobxObservable,
|
|
3
4
|
computed as mobxComputed,
|
|
4
5
|
IObservableValue as mobxIObservableValue,
|
|
@@ -18,10 +19,6 @@
|
|
|
18
19
|
|
|
19
20
|
import { observable as jpfObservable } from "jpf";
|
|
20
21
|
|
|
21
|
-
export function runInAction<T>(fn: () => T): T {
|
|
22
|
-
return mobxRunInAction<T>(fn);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
22
|
function setDefaultOptions<TOptions>(target: TOptions, source: TOptions): TOptions {
|
|
26
23
|
if (source) {
|
|
27
24
|
target = target || {} as TOptions;
|
|
@@ -35,7 +32,19 @@ function setDefaultOptions<TOptions>(target: TOptions, source: TOptions): TOptio
|
|
|
35
32
|
return target;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
function
|
|
35
|
+
export function runInAction<T>(fn: () => T): T {
|
|
36
|
+
return mobxRunInAction<T>(fn);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type IComputed<TValue> = jpfObservable.IComputed<TValue>
|
|
40
|
+
export type IDisposer = jpfObservable.IDisposer
|
|
41
|
+
export type IObservableArray<TItem = any, TSetter = TItem[]> = jpfObservable.IObservableArray<TItem, TSetter>
|
|
42
|
+
export type IObservableMap<TKey = unknown, TItem = unknown> = jpfObservable.IObservableMap<TKey, TItem>
|
|
43
|
+
export type IObservableSet<TItem = unknown> = jpfObservable.IObservableSet<TItem>
|
|
44
|
+
export type IObservableValue<TValue, TSetter = TValue> = jpfObservable.IObservableValue<TValue, TSetter>
|
|
45
|
+
export type ISubscribable<TValue> = jpfObservable.ISubscribable<TValue>;
|
|
46
|
+
|
|
47
|
+
export function unwrap<TValue>(value: TValue | jpfObservable.ISubscribable<TValue>): TValue {
|
|
39
48
|
if (mobxIsComputed(value) || mobxIsObservableValue(value)) {
|
|
40
49
|
return (value as mobxIObservableValue<TValue>).get();
|
|
41
50
|
}
|
|
@@ -55,27 +64,27 @@ function unwrap<TValue>(value: TValue | jpfObservable.ISubscribable<TValue>): TV
|
|
|
55
64
|
return value as TValue;
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
function isComputed<TValue>(value: unknown): value is jpfObservable.IComputed<TValue> {
|
|
67
|
+
export function isComputed<TValue>(value: unknown): value is jpfObservable.IComputed<TValue> {
|
|
59
68
|
return mobxIsComputed(value);
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
function isObservableValue(value): value is jpfObservable.IObservableValue {
|
|
71
|
+
export function isObservableValue(value): value is jpfObservable.IObservableValue {
|
|
63
72
|
return mobxIsObservableValue(value);
|
|
64
73
|
}
|
|
65
74
|
|
|
66
|
-
function isObservableArray(value): value is jpfObservable.IObservableArray {
|
|
75
|
+
export function isObservableArray(value): value is jpfObservable.IObservableArray {
|
|
67
76
|
return mobxIsObservableArray(value);
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
function isObservableMap<TKey, TItem>(value): value is jpfObservable.IObservableMap<TKey, TItem> {
|
|
79
|
+
export function isObservableMap<TKey, TItem>(value): value is jpfObservable.IObservableMap<TKey, TItem> {
|
|
71
80
|
return mobxIsObservableMap(value);
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
function isObservableSet<TItem>(value): value is jpfObservable.IObservableSet<TItem> {
|
|
83
|
+
export function isObservableSet<TItem>(value): value is jpfObservable.IObservableSet<TItem> {
|
|
75
84
|
return mobxIsObservableSet(value);
|
|
76
85
|
}
|
|
77
86
|
|
|
78
|
-
function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>): jpfObservable.IComputed<TComputed> {
|
|
87
|
+
export function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValueOptions<TComputed>): jpfObservable.IComputed<TComputed> {
|
|
79
88
|
const computed = mobxComputed(func, options);
|
|
80
89
|
const iComputed = computed as unknown as jpfObservable.IComputed<TComputed>;
|
|
81
90
|
|
|
@@ -93,7 +102,7 @@ function computed<TComputed>(func: () => TComputed, options?: mobxIComputedValue
|
|
|
93
102
|
return iComputed;
|
|
94
103
|
}
|
|
95
104
|
|
|
96
|
-
function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: jpfObservable.IObservableValue<TValue, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableValue<TValue, TSetter> {
|
|
105
|
+
export function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter?: (value: TSetter, observableValue: jpfObservable.IObservableValue<TValue, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableValue<TValue, TSetter> {
|
|
97
106
|
//Make sure deep is set to false if not provided
|
|
98
107
|
setDefaultOptions(options, { deep: false });
|
|
99
108
|
|
|
@@ -143,7 +152,7 @@ function observableValue<TValue, TSetter = TValue>(value?: TValue | null, setter
|
|
|
143
152
|
return observableValue;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
|
-
function observableArray<TItem = unknown, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: jpfObservable.IObservableArray<TItem, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableArray<TItem, TSetter> {
|
|
155
|
+
export function observableArray<TItem = unknown, TSetter = Array<TItem>>(initialValues?: Array<TItem> | null, setter?: (value: TSetter, observableArray: jpfObservable.IObservableArray<TItem, TSetter>) => void, options?: mobxCreateObservableOptions): jpfObservable.IObservableArray<TItem, TSetter> {
|
|
147
156
|
//Make sure deep is set to false if not provided
|
|
148
157
|
options = setDefaultOptions(options, { deep: false });
|
|
149
158
|
|
|
@@ -190,7 +199,7 @@ function observableArray<TItem = unknown, TSetter = Array<TItem>>(initialValues?
|
|
|
190
199
|
return observableArray;
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
function observableMap<TKey = unknown, TItem = unknown>(initialValues?: mobxIMapEntries<TKey, TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableMap<TKey, TItem> {
|
|
202
|
+
export function observableMap<TKey = unknown, TItem = unknown>(initialValues?: mobxIMapEntries<TKey, TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableMap<TKey, TItem> {
|
|
194
203
|
//Add a deep property if the property does not already exist
|
|
195
204
|
const defaultOptions = { deep: false };
|
|
196
205
|
options = { ...defaultOptions, ...options };
|
|
@@ -198,7 +207,7 @@ function observableMap<TKey = unknown, TItem = unknown>(initialValues?: mobxIMap
|
|
|
198
207
|
return mobxObservable.map<TKey, TItem>(initialValues, options);
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
function observableSet<TItem = unknown>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableSet<TItem> {
|
|
210
|
+
export function observableSet<TItem = unknown>(initialValues?: mobxIObservableSetInitialValues<TItem>, options?: mobxCreateObservableOptions): jpfObservable.IObservableSet<TItem> {
|
|
202
211
|
//Add a deep property if the property does not already exist
|
|
203
212
|
const defaultOptions = { deep: false };
|
|
204
213
|
options = { ...defaultOptions, ...options };
|