as-model 0.1.6 → 0.1.8
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.js +8 -4
- package/esm/index.js +2 -0
- package/esm/store/instance.js +1 -1
- package/esm/updater/notifier.js +7 -3
- package/index.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -233,20 +233,24 @@
|
|
|
233
233
|
var dispatches = updater.dispatches, controlled = updater.controlled;
|
|
234
234
|
var dispatchCallbacks = _to_consumable_array(dispatches);
|
|
235
235
|
var state = action.state;
|
|
236
|
+
var nextInstance = model2(state);
|
|
237
|
+
var nextAction = _object_spread_props(_object_spread({}, action), {
|
|
238
|
+
instance: nextInstance
|
|
239
|
+
});
|
|
236
240
|
if (!controlled) {
|
|
237
241
|
updater.mutate(function(u) {
|
|
238
242
|
return _object_spread_props(_object_spread({}, u), {
|
|
239
243
|
state,
|
|
240
|
-
instance:
|
|
244
|
+
instance: nextInstance,
|
|
241
245
|
version: u.version + 1
|
|
242
246
|
});
|
|
243
247
|
});
|
|
244
248
|
}
|
|
245
249
|
try {
|
|
246
250
|
if (typeof config2.batchNotify === "function") {
|
|
247
|
-
config2.batchNotify(dispatchCallbacks,
|
|
251
|
+
config2.batchNotify(dispatchCallbacks, nextAction);
|
|
248
252
|
} else {
|
|
249
|
-
defaultNotifyImplement(dispatchCallbacks,
|
|
253
|
+
defaultNotifyImplement(dispatchCallbacks, nextAction);
|
|
250
254
|
}
|
|
251
255
|
} catch (e) {
|
|
252
256
|
updater.mutate(function(u) {
|
|
@@ -687,7 +691,7 @@
|
|
|
687
691
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
688
692
|
args[_key] = arguments[_key];
|
|
689
693
|
}
|
|
690
|
-
var instance = updater.instance
|
|
694
|
+
var instance = updater.instance;
|
|
691
695
|
var method2 = instance[methodName];
|
|
692
696
|
if (typeof method2 !== "function") {
|
|
693
697
|
throw new Error("Can not change methods in runtime.");
|
package/esm/index.js
CHANGED
|
@@ -38,6 +38,7 @@ function config() {
|
|
|
38
38
|
var _config = config(), createStore = _config.createStore, createKey = _config.createKey, createStores = _config.createStores, model = _config.model;
|
|
39
39
|
import { createSignal, createSelector } from "./store";
|
|
40
40
|
import { validations } from "./validation";
|
|
41
|
+
import { shallowEqual } from "./tools";
|
|
41
42
|
export {
|
|
42
43
|
config,
|
|
43
44
|
createKey,
|
|
@@ -46,5 +47,6 @@ export {
|
|
|
46
47
|
createStore,
|
|
47
48
|
createStores,
|
|
48
49
|
model,
|
|
50
|
+
shallowEqual,
|
|
49
51
|
validations
|
|
50
52
|
};
|
package/esm/store/instance.js
CHANGED
|
@@ -66,7 +66,7 @@ function wrapToActionMethod(updater, methodName) {
|
|
|
66
66
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
67
67
|
args[_key] = arguments[_key];
|
|
68
68
|
}
|
|
69
|
-
var instance = updater.instance
|
|
69
|
+
var instance = updater.instance;
|
|
70
70
|
var method2 = instance[methodName];
|
|
71
71
|
if (typeof method2 !== "function") {
|
|
72
72
|
throw new Error("Can not change methods in runtime.");
|
package/esm/updater/notifier.js
CHANGED
|
@@ -80,20 +80,24 @@ function generateNotifier(updater, middleWare) {
|
|
|
80
80
|
var dispatches = updater.dispatches, controlled = updater.controlled;
|
|
81
81
|
var dispatchCallbacks = _to_consumable_array(dispatches);
|
|
82
82
|
var state = action.state;
|
|
83
|
+
var nextInstance = model(state);
|
|
84
|
+
var nextAction = _object_spread_props(_object_spread({}, action), {
|
|
85
|
+
instance: nextInstance
|
|
86
|
+
});
|
|
83
87
|
if (!controlled) {
|
|
84
88
|
updater.mutate(function(u) {
|
|
85
89
|
return _object_spread_props(_object_spread({}, u), {
|
|
86
90
|
state,
|
|
87
|
-
instance:
|
|
91
|
+
instance: nextInstance,
|
|
88
92
|
version: u.version + 1
|
|
89
93
|
});
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
try {
|
|
93
97
|
if (typeof config.batchNotify === "function") {
|
|
94
|
-
config.batchNotify(dispatchCallbacks,
|
|
98
|
+
config.batchNotify(dispatchCallbacks, nextAction);
|
|
95
99
|
} else {
|
|
96
|
-
defaultNotifyImplement(dispatchCallbacks,
|
|
100
|
+
defaultNotifyImplement(dispatchCallbacks, nextAction);
|
|
97
101
|
}
|
|
98
102
|
} catch (e) {
|
|
99
103
|
updater.mutate(function(u) {
|
package/index.d.ts
CHANGED