@expressive/mvc 0.36.1 → 0.36.2
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 +1 -1
- package/dist/index.js +14 -3
- package/dist/index.mjs +14 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare namespace Model {
|
|
|
28
28
|
current: T | null;
|
|
29
29
|
};
|
|
30
30
|
/** A callback function which is subscribed to parent and updates when values change. */
|
|
31
|
-
type Effect<T> = (this: T,
|
|
31
|
+
type Effect<T> = (this: T, current: T, updated: Set<Model.Key<T>>) => ((update: boolean | null) => void) | Promise<void> | null | void;
|
|
32
32
|
type Event<T extends Model> = (this: T, key: unknown, source: T) => (() => void) | void | null;
|
|
33
33
|
namespace Instruction {
|
|
34
34
|
type Getter<T> = (source: Model) => T;
|
package/dist/index.js
CHANGED
|
@@ -181,8 +181,17 @@ var Model = class _Model {
|
|
|
181
181
|
}
|
|
182
182
|
get(arg1, arg2) {
|
|
183
183
|
const self = this.is;
|
|
184
|
-
if (typeof arg1 == "function")
|
|
185
|
-
|
|
184
|
+
if (typeof arg1 == "function") {
|
|
185
|
+
let pending = /* @__PURE__ */ new Set();
|
|
186
|
+
return effect(self, (state) => {
|
|
187
|
+
const cb = arg1.call(state, state, pending);
|
|
188
|
+
return cb === null ? null : (update2) => {
|
|
189
|
+
pending = PENDING2.get(self);
|
|
190
|
+
if (typeof cb == "function")
|
|
191
|
+
return cb(update2);
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
}
|
|
186
195
|
if (arg1 === void 0)
|
|
187
196
|
return extract(self);
|
|
188
197
|
if (typeof arg2 == "function") {
|
|
@@ -366,7 +375,9 @@ function add(instruction) {
|
|
|
366
375
|
}
|
|
367
376
|
Model.on((_, subject) => {
|
|
368
377
|
const state = STATE.get(subject);
|
|
369
|
-
Object.entries(
|
|
378
|
+
Object.entries(
|
|
379
|
+
Object.getOwnPropertyDescriptors(subject)
|
|
380
|
+
).forEach(([key, { value }]) => {
|
|
370
381
|
const instruction = INSTRUCT.get(value);
|
|
371
382
|
if (!instruction)
|
|
372
383
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -148,8 +148,17 @@ var Model = class _Model {
|
|
|
148
148
|
}
|
|
149
149
|
get(arg1, arg2) {
|
|
150
150
|
const self = this.is;
|
|
151
|
-
if (typeof arg1 == "function")
|
|
152
|
-
|
|
151
|
+
if (typeof arg1 == "function") {
|
|
152
|
+
let pending = /* @__PURE__ */ new Set();
|
|
153
|
+
return effect(self, (state) => {
|
|
154
|
+
const cb = arg1.call(state, state, pending);
|
|
155
|
+
return cb === null ? null : (update2) => {
|
|
156
|
+
pending = PENDING2.get(self);
|
|
157
|
+
if (typeof cb == "function")
|
|
158
|
+
return cb(update2);
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
153
162
|
if (arg1 === void 0)
|
|
154
163
|
return extract(self);
|
|
155
164
|
if (typeof arg2 == "function") {
|
|
@@ -333,7 +342,9 @@ function add(instruction) {
|
|
|
333
342
|
}
|
|
334
343
|
Model.on((_, subject) => {
|
|
335
344
|
const state = STATE.get(subject);
|
|
336
|
-
Object.entries(
|
|
345
|
+
Object.entries(
|
|
346
|
+
Object.getOwnPropertyDescriptors(subject)
|
|
347
|
+
).forEach(([key, { value }]) => {
|
|
337
348
|
const instruction = INSTRUCT.get(value);
|
|
338
349
|
if (!instruction)
|
|
339
350
|
return;
|
package/package.json
CHANGED