@kuindji/reactive 1.0.23 → 1.1.0
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/README.md +34 -11
- package/dist/action.d.ts +12 -10
- package/dist/action.js +23 -16
- package/dist/actionBus.d.ts +8 -4
- package/dist/actionBus.js +37 -8
- package/dist/actionMap.d.ts +21 -19
- package/dist/actionMap.js +12 -9
- package/dist/event.d.ts +3 -2
- package/dist/event.js +160 -109
- package/dist/eventBus.d.ts +5 -3
- package/dist/eventBus.js +158 -104
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -23
- package/dist/lib/actionMapInternal.d.ts +8 -0
- package/dist/lib/actionMapInternal.js +8 -0
- package/dist/lib/asyncCall.js +1 -4
- package/dist/lib/isPromiseLike.d.ts +1 -0
- package/dist/lib/isPromiseLike.js +5 -0
- package/dist/lib/listenerSorter.js +1 -4
- package/dist/lib/normalizeEventOptions.d.ts +13 -0
- package/dist/lib/normalizeEventOptions.js +21 -0
- package/dist/lib/tagsIntersect.js +1 -4
- package/dist/lib/types.js +4 -7
- package/dist/react/ErrorBoundary.d.ts +1 -1
- package/dist/react/ErrorBoundary.js +10 -13
- package/dist/react/listenerOptionsEqual.d.ts +27 -0
- package/dist/react/listenerOptionsEqual.js +121 -0
- package/dist/react/useAction.d.ts +3 -3
- package/dist/react/useAction.js +25 -25
- package/dist/react/useActionBus.d.ts +4 -4
- package/dist/react/useActionBus.js +41 -14
- package/dist/react/useActionMap.d.ts +4 -4
- package/dist/react/useActionMap.js +46 -16
- package/dist/react/useEvent.d.ts +2 -2
- package/dist/react/useEvent.js +30 -17
- package/dist/react/useEventBus.d.ts +2 -2
- package/dist/react/useEventBus.js +27 -26
- package/dist/react/useListenToAction.d.ts +1 -1
- package/dist/react/useListenToAction.js +24 -48
- package/dist/react/useListenToActionBus.d.ts +3 -3
- package/dist/react/useListenToActionBus.js +22 -19
- package/dist/react/useListenToEvent.d.ts +2 -2
- package/dist/react/useListenToEvent.js +13 -14
- package/dist/react/useListenToEventBus.d.ts +3 -3
- package/dist/react/useListenToEventBus.js +14 -15
- package/dist/react/useListenToStoreChanges.d.ts +3 -3
- package/dist/react/useListenToStoreChanges.js +12 -13
- package/dist/react/useReconciledListener.d.ts +33 -0
- package/dist/react/useReconciledListener.js +44 -0
- package/dist/react/useStore.d.ts +2 -2
- package/dist/react/useStore.js +72 -23
- package/dist/react/useStoreState.d.ts +2 -2
- package/dist/react/useStoreState.js +16 -26
- package/dist/react.d.ts +13 -13
- package/dist/react.js +13 -29
- package/dist/store.d.ts +9 -8
- package/dist/store.js +116 -53
- package/package.json +13 -3
package/dist/react.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from "./react/ErrorBoundary";
|
|
2
|
-
export * from "./react/useAction";
|
|
3
|
-
export * from "./react/useActionBus";
|
|
4
|
-
export * from "./react/useActionMap";
|
|
5
|
-
export * from "./react/useEvent";
|
|
6
|
-
export * from "./react/useEventBus";
|
|
7
|
-
export * from "./react/useListenToAction";
|
|
8
|
-
export * from "./react/useListenToActionBus";
|
|
9
|
-
export * from "./react/useListenToEvent";
|
|
10
|
-
export * from "./react/useListenToEventBus";
|
|
11
|
-
export * from "./react/useListenToStoreChanges";
|
|
12
|
-
export * from "./react/useStore";
|
|
13
|
-
export * from "./react/useStoreState";
|
|
1
|
+
export * from "./react/ErrorBoundary.js";
|
|
2
|
+
export * from "./react/useAction.js";
|
|
3
|
+
export * from "./react/useActionBus.js";
|
|
4
|
+
export * from "./react/useActionMap.js";
|
|
5
|
+
export * from "./react/useEvent.js";
|
|
6
|
+
export * from "./react/useEventBus.js";
|
|
7
|
+
export * from "./react/useListenToAction.js";
|
|
8
|
+
export * from "./react/useListenToActionBus.js";
|
|
9
|
+
export * from "./react/useListenToEvent.js";
|
|
10
|
+
export * from "./react/useListenToEventBus.js";
|
|
11
|
+
export * from "./react/useListenToStoreChanges.js";
|
|
12
|
+
export * from "./react/useStore.js";
|
|
13
|
+
export * from "./react/useStoreState.js";
|
package/dist/react.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./react/ErrorBoundary"), exports);
|
|
18
|
-
__exportStar(require("./react/useAction"), exports);
|
|
19
|
-
__exportStar(require("./react/useActionBus"), exports);
|
|
20
|
-
__exportStar(require("./react/useActionMap"), exports);
|
|
21
|
-
__exportStar(require("./react/useEvent"), exports);
|
|
22
|
-
__exportStar(require("./react/useEventBus"), exports);
|
|
23
|
-
__exportStar(require("./react/useListenToAction"), exports);
|
|
24
|
-
__exportStar(require("./react/useListenToActionBus"), exports);
|
|
25
|
-
__exportStar(require("./react/useListenToEvent"), exports);
|
|
26
|
-
__exportStar(require("./react/useListenToEventBus"), exports);
|
|
27
|
-
__exportStar(require("./react/useListenToStoreChanges"), exports);
|
|
28
|
-
__exportStar(require("./react/useStore"), exports);
|
|
29
|
-
__exportStar(require("./react/useStoreState"), exports);
|
|
1
|
+
export * from "./react/ErrorBoundary.js";
|
|
2
|
+
export * from "./react/useAction.js";
|
|
3
|
+
export * from "./react/useActionBus.js";
|
|
4
|
+
export * from "./react/useActionMap.js";
|
|
5
|
+
export * from "./react/useEvent.js";
|
|
6
|
+
export * from "./react/useEventBus.js";
|
|
7
|
+
export * from "./react/useListenToAction.js";
|
|
8
|
+
export * from "./react/useListenToActionBus.js";
|
|
9
|
+
export * from "./react/useListenToEvent.js";
|
|
10
|
+
export * from "./react/useListenToEventBus.js";
|
|
11
|
+
export * from "./react/useListenToStoreChanges.js";
|
|
12
|
+
export * from "./react/useStore.js";
|
|
13
|
+
export * from "./react/useStoreState.js";
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventBusDefinitionHelper } from "./eventBus";
|
|
2
|
-
import type { ApiType, ErrorListenerSignature, KeyOf, MapKey } from "./lib/types";
|
|
1
|
+
import { EventBusDefinitionHelper } from "./eventBus.js";
|
|
2
|
+
import type { ApiType, ErrorListenerSignature, KeyOf, MapKey } from "./lib/types.js";
|
|
3
3
|
export interface BasePropMap {
|
|
4
4
|
[key: MapKey]: any;
|
|
5
5
|
}
|
|
@@ -44,12 +44,13 @@ export declare function createStore<PropMap extends BasePropMap = BasePropMap>(i
|
|
|
44
44
|
};
|
|
45
45
|
readonly isEmpty: () => boolean;
|
|
46
46
|
readonly reset: () => void;
|
|
47
|
-
readonly onChange: <K extends KeyOf<import("./eventBus").GetEventsMap<StoreChangeEvents<PropMap>>>, H extends import("./eventBus").GetEventsMap<StoreChangeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, options?: import("./event").ListenerOptions) => void;
|
|
48
|
-
readonly removeOnChange: <K extends KeyOf<import("./eventBus").GetEventsMap<StoreChangeEvents<PropMap>>>, H extends import("./eventBus").GetEventsMap<StoreChangeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, context?: object | null, tag?: string | null) => void;
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
47
|
+
readonly onChange: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, options?: import("./event.js").ListenerOptions) => void;
|
|
48
|
+
readonly removeOnChange: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, context?: object | null, tag?: string | null) => void;
|
|
49
|
+
readonly updateOnChangeOptions: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StoreChangeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, context?: object | null, nextOptions?: import("./event.js").ListenerOptions) => boolean;
|
|
50
|
+
readonly control: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StoreControlEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StoreControlEvents<PropMap>>[K]["signature"]>(name: K, handler: H, options?: import("./event.js").ListenerOptions) => void;
|
|
51
|
+
readonly removeControl: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StoreControlEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StoreControlEvents<PropMap>>[K]["signature"]>(name: K, handler: H, context?: object | null, tag?: string | null) => void;
|
|
52
|
+
readonly pipe: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StorePipeEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StorePipeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, options?: import("./event.js").ListenerOptions) => void;
|
|
53
|
+
readonly removePipe: <K extends KeyOf<import("./eventBus.js").GetEventsMap<StorePipeEvents<PropMap>>>, H extends import("./eventBus.js").GetEventsMap<StorePipeEvents<PropMap>>[K]["signature"]>(name: K, handler: H, context?: object | null, tag?: string | null) => void;
|
|
53
54
|
}>;
|
|
54
55
|
export type BaseStoreDefinition = StoreDefinitionHelper<BasePropMap>;
|
|
55
56
|
export type BaseStore = ReturnType<typeof createStore<any>>;
|
package/dist/store.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.ResetEventName = "reset";
|
|
9
|
-
exports.ErrorEventName = "error";
|
|
10
|
-
exports.EffectEventName = "effect";
|
|
11
|
-
function createStore(initialData = {}) {
|
|
1
|
+
import { createEventBus } from "./eventBus.js";
|
|
2
|
+
export const BeforeChangeEventName = "before";
|
|
3
|
+
export const ChangeEventName = "change";
|
|
4
|
+
export const ResetEventName = "reset";
|
|
5
|
+
export const ErrorEventName = "error";
|
|
6
|
+
export const EffectEventName = "effect";
|
|
7
|
+
export function createStore(initialData = {}) {
|
|
12
8
|
const data = new Map(Object.entries(initialData));
|
|
13
|
-
const changes =
|
|
14
|
-
const pipe =
|
|
15
|
-
const control =
|
|
9
|
+
const changes = createEventBus();
|
|
10
|
+
const pipe = createEventBus();
|
|
11
|
+
const control = createEventBus();
|
|
16
12
|
let effectKeys = [];
|
|
17
13
|
const effectInterceptor = (name, args) => {
|
|
18
|
-
if (name ===
|
|
14
|
+
if (name === ChangeEventName) {
|
|
19
15
|
effectKeys.push(...args[0]);
|
|
20
16
|
return false;
|
|
21
17
|
}
|
|
@@ -25,8 +21,8 @@ function createStore(initialData = {}) {
|
|
|
25
21
|
var _a, _b, _c, _d, _e;
|
|
26
22
|
const prev = data.get(name);
|
|
27
23
|
if (prev !== value) {
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const beforeChangeResults = control.all(BeforeChangeEventName, name, value);
|
|
25
|
+
if (beforeChangeResults.some((result) => result === false)) {
|
|
30
26
|
return;
|
|
31
27
|
}
|
|
32
28
|
const pipeArgs = [value];
|
|
@@ -35,7 +31,7 @@ function createStore(initialData = {}) {
|
|
|
35
31
|
newValue = pipe.pipe(name, ...pipeArgs);
|
|
36
32
|
}
|
|
37
33
|
catch (error) {
|
|
38
|
-
control.trigger(
|
|
34
|
+
control.trigger(ErrorEventName, {
|
|
39
35
|
error: error instanceof Error
|
|
40
36
|
? error
|
|
41
37
|
: new Error(String(error)),
|
|
@@ -43,7 +39,7 @@ function createStore(initialData = {}) {
|
|
|
43
39
|
type: "store-pipe",
|
|
44
40
|
name,
|
|
45
41
|
});
|
|
46
|
-
if ((_a = control.get(
|
|
42
|
+
if ((_a = control.get(ErrorEventName)) === null || _a === void 0 ? void 0 : _a.hasListener()) {
|
|
47
43
|
return false;
|
|
48
44
|
}
|
|
49
45
|
throw error;
|
|
@@ -60,7 +56,7 @@ function createStore(initialData = {}) {
|
|
|
60
56
|
changes.trigger(name, ...changeArgs);
|
|
61
57
|
}
|
|
62
58
|
catch (error) {
|
|
63
|
-
control.trigger(
|
|
59
|
+
control.trigger(ErrorEventName, {
|
|
64
60
|
error: error instanceof Error
|
|
65
61
|
? error
|
|
66
62
|
: new Error(String(error)),
|
|
@@ -68,25 +64,29 @@ function createStore(initialData = {}) {
|
|
|
68
64
|
type: "store-change",
|
|
69
65
|
name,
|
|
70
66
|
});
|
|
71
|
-
if ((_b = control.get(
|
|
67
|
+
if ((_b = control.get(ErrorEventName)) === null || _b === void 0 ? void 0 : _b.hasListener()) {
|
|
72
68
|
effectKeys = [];
|
|
73
69
|
return true;
|
|
74
70
|
}
|
|
75
71
|
throw error;
|
|
76
72
|
}
|
|
77
|
-
if ((_c = control.get(
|
|
73
|
+
if ((_c = control.get(EffectEventName)) === null || _c === void 0 ? void 0 : _c.hasListener()) {
|
|
78
74
|
try {
|
|
79
75
|
const isIntercepting = control.isIntercepting();
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
try {
|
|
77
|
+
if (!isIntercepting) {
|
|
78
|
+
control.intercept(effectInterceptor);
|
|
79
|
+
}
|
|
80
|
+
control.trigger(EffectEventName, name, value);
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
finally {
|
|
83
|
+
if (!isIntercepting) {
|
|
84
|
+
control.stopIntercepting();
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
catch (error) {
|
|
89
|
-
control.trigger(
|
|
89
|
+
control.trigger(ErrorEventName, {
|
|
90
90
|
error: error instanceof Error
|
|
91
91
|
? error
|
|
92
92
|
: new Error(String(error)),
|
|
@@ -94,7 +94,7 @@ function createStore(initialData = {}) {
|
|
|
94
94
|
type: "store-control",
|
|
95
95
|
name,
|
|
96
96
|
});
|
|
97
|
-
if ((_d = control.get(
|
|
97
|
+
if ((_d = control.get(ErrorEventName)) === null || _d === void 0 ? void 0 : _d.hasListener()) {
|
|
98
98
|
effectKeys = [];
|
|
99
99
|
return true;
|
|
100
100
|
}
|
|
@@ -103,13 +103,13 @@ function createStore(initialData = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
if (triggerChange) {
|
|
105
105
|
try {
|
|
106
|
-
control.trigger(
|
|
106
|
+
control.trigger(ChangeEventName, [name, ...effectKeys]);
|
|
107
107
|
if (!control.isIntercepting()) {
|
|
108
108
|
effectKeys = [];
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
catch (error) {
|
|
112
|
-
control.trigger(
|
|
112
|
+
control.trigger(ErrorEventName, {
|
|
113
113
|
error: error instanceof Error
|
|
114
114
|
? error
|
|
115
115
|
: new Error(String(error)),
|
|
@@ -117,7 +117,7 @@ function createStore(initialData = {}) {
|
|
|
117
117
|
type: "store-control",
|
|
118
118
|
name,
|
|
119
119
|
});
|
|
120
|
-
if ((_e = control.get(
|
|
120
|
+
if ((_e = control.get(ErrorEventName)) === null || _e === void 0 ? void 0 : _e.hasListener()) {
|
|
121
121
|
effectKeys = [];
|
|
122
122
|
return true;
|
|
123
123
|
}
|
|
@@ -146,37 +146,49 @@ function createStore(initialData = {}) {
|
|
|
146
146
|
else if (typeof name === "object") {
|
|
147
147
|
const changedKeys = [];
|
|
148
148
|
const isIntercepting = control.isIntercepting();
|
|
149
|
-
const hasEffectListener = (_a = control.get(
|
|
150
|
-
|
|
149
|
+
const hasEffectListener = (_a = control.get(EffectEventName)) === null || _a === void 0 ? void 0 : _a.hasListener();
|
|
150
|
+
const shouldInterceptEffects = hasEffectListener && !isIntercepting;
|
|
151
|
+
let controlError = null;
|
|
152
|
+
if (shouldInterceptEffects) {
|
|
151
153
|
control.intercept(effectInterceptor);
|
|
152
154
|
}
|
|
153
|
-
Object.entries(name).forEach(([k, v]) => {
|
|
154
|
-
if (_set(k, v, false)) {
|
|
155
|
-
changedKeys.push(k);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
155
|
try {
|
|
159
|
-
|
|
156
|
+
Object.entries(name).forEach(([k, v]) => {
|
|
157
|
+
if (_set(k, v, false)) {
|
|
158
|
+
changedKeys.push(k);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const allChangedKeys = [
|
|
160
162
|
...changedKeys,
|
|
161
163
|
...effectKeys,
|
|
162
|
-
]
|
|
163
|
-
if (
|
|
164
|
+
];
|
|
165
|
+
if (allChangedKeys.length > 0) {
|
|
166
|
+
try {
|
|
167
|
+
control.trigger(ChangeEventName, allChangedKeys);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
controlError = error instanceof Error
|
|
171
|
+
? error
|
|
172
|
+
: new Error(String(error));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
if (shouldInterceptEffects) {
|
|
164
178
|
effectKeys = [];
|
|
165
179
|
control.stopIntercepting();
|
|
166
180
|
}
|
|
167
181
|
}
|
|
168
|
-
|
|
169
|
-
control.trigger(
|
|
170
|
-
error:
|
|
171
|
-
? error
|
|
172
|
-
: new Error(String(error)),
|
|
182
|
+
if (controlError) {
|
|
183
|
+
control.trigger(ErrorEventName, {
|
|
184
|
+
error: controlError,
|
|
173
185
|
args: [name],
|
|
174
186
|
type: "store-control",
|
|
175
187
|
});
|
|
176
|
-
if ((_b = control.get(
|
|
188
|
+
if ((_b = control.get(ErrorEventName)) === null || _b === void 0 ? void 0 : _b.hasListener()) {
|
|
177
189
|
return;
|
|
178
190
|
}
|
|
179
|
-
throw
|
|
191
|
+
throw controlError;
|
|
180
192
|
}
|
|
181
193
|
}
|
|
182
194
|
else {
|
|
@@ -211,6 +223,7 @@ function createStore(initialData = {}) {
|
|
|
211
223
|
};
|
|
212
224
|
let batching = false;
|
|
213
225
|
const batch = (fn) => {
|
|
226
|
+
var _a, _b;
|
|
214
227
|
if (batching) {
|
|
215
228
|
throw new Error("Nested batch() calls are not supported");
|
|
216
229
|
}
|
|
@@ -218,7 +231,7 @@ function createStore(initialData = {}) {
|
|
|
218
231
|
const allChangedKeys = [];
|
|
219
232
|
const log = [];
|
|
220
233
|
const controlInterceptor = function (name, [changedKeys]) {
|
|
221
|
-
if (name ===
|
|
234
|
+
if (name === ChangeEventName) {
|
|
222
235
|
allChangedKeys.push(...changedKeys);
|
|
223
236
|
return false;
|
|
224
237
|
}
|
|
@@ -230,9 +243,15 @@ function createStore(initialData = {}) {
|
|
|
230
243
|
};
|
|
231
244
|
changes.intercept(changeInterceptor);
|
|
232
245
|
control.intercept(controlInterceptor);
|
|
246
|
+
let callbackError;
|
|
247
|
+
let hasCallbackError = false;
|
|
233
248
|
try {
|
|
234
249
|
fn();
|
|
235
250
|
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
callbackError = error;
|
|
253
|
+
hasCallbackError = true;
|
|
254
|
+
}
|
|
236
255
|
finally {
|
|
237
256
|
control.stopIntercepting();
|
|
238
257
|
changes.stopIntercepting();
|
|
@@ -243,15 +262,58 @@ function createStore(initialData = {}) {
|
|
|
243
262
|
value,
|
|
244
263
|
prev,
|
|
245
264
|
];
|
|
246
|
-
|
|
265
|
+
try {
|
|
266
|
+
changes.trigger(propName, ...changeArgs);
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
control.trigger(ErrorEventName, {
|
|
270
|
+
error: error instanceof Error
|
|
271
|
+
? error
|
|
272
|
+
: new Error(String(error)),
|
|
273
|
+
args: changeArgs,
|
|
274
|
+
type: "store-change",
|
|
275
|
+
name: propName,
|
|
276
|
+
});
|
|
277
|
+
if ((_a = control.get(ErrorEventName)) === null || _a === void 0 ? void 0 : _a.hasListener()) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (hasCallbackError) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
247
285
|
}
|
|
248
286
|
if (allChangedKeys.length > 0) {
|
|
249
|
-
|
|
287
|
+
try {
|
|
288
|
+
control.trigger(ChangeEventName, allChangedKeys);
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
control.trigger(ErrorEventName, {
|
|
292
|
+
error: error instanceof Error
|
|
293
|
+
? error
|
|
294
|
+
: new Error(String(error)),
|
|
295
|
+
args: [allChangedKeys],
|
|
296
|
+
type: "store-control",
|
|
297
|
+
});
|
|
298
|
+
if ((_b = control.get(ErrorEventName)) === null || _b === void 0 ? void 0 : _b.hasListener()) {
|
|
299
|
+
if (hasCallbackError) {
|
|
300
|
+
throw callbackError;
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (hasCallbackError) {
|
|
305
|
+
throw callbackError;
|
|
306
|
+
}
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (hasCallbackError) {
|
|
311
|
+
throw callbackError;
|
|
250
312
|
}
|
|
251
313
|
};
|
|
252
314
|
const reset = () => {
|
|
253
315
|
data.clear();
|
|
254
|
-
control.trigger(
|
|
316
|
+
control.trigger(ResetEventName);
|
|
255
317
|
};
|
|
256
318
|
const api = {
|
|
257
319
|
set,
|
|
@@ -263,6 +325,7 @@ function createStore(initialData = {}) {
|
|
|
263
325
|
reset,
|
|
264
326
|
onChange: changes.addListener,
|
|
265
327
|
removeOnChange: changes.removeListener,
|
|
328
|
+
updateOnChangeOptions: changes.updateListenerOptions,
|
|
266
329
|
control: control.addListener,
|
|
267
330
|
removeControl: control.removeListener,
|
|
268
331
|
pipe: pipe.addListener,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuindji/reactive",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"author": "Ivan Kuindzhi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
"typescript": "^5.9.3",
|
|
23
23
|
"typescript-eslint": "^8.48.0"
|
|
24
24
|
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=18.0.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"react": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
25
33
|
"exports": {
|
|
26
34
|
".": {
|
|
27
35
|
"types": "./dist/index.d.ts",
|
|
@@ -62,11 +70,13 @@
|
|
|
62
70
|
"license": "ISC",
|
|
63
71
|
"scripts": {
|
|
64
72
|
"build": "tsc -p ./tsconfig-build.json",
|
|
73
|
+
"prepublishOnly": "bun run build",
|
|
65
74
|
"lint": "bun eslint .",
|
|
75
|
+
"type-check": "tsc --noEmit",
|
|
66
76
|
"test": "bun test tests/**/*.spec.ts*",
|
|
67
77
|
"test:types": "tsc -p ./tests/types/tsconfig.json",
|
|
68
|
-
"test:all": "bun run test:types && bun run test"
|
|
78
|
+
"test:all": "bun run type-check && bun run test:types && bun run test"
|
|
69
79
|
},
|
|
70
80
|
"sideEffects": false,
|
|
71
81
|
"types": "dist/index.d.ts"
|
|
72
|
-
}
|
|
82
|
+
}
|