@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 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, argument: T) => ((update: boolean | null) => void) | Promise<void> | null | void;
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
- return effect(self, arg1);
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(Object.getOwnPropertyDescriptors(subject)).forEach(([key, { value }]) => {
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
- return effect(self, arg1);
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(Object.getOwnPropertyDescriptors(subject)).forEach(([key, { value }]) => {
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
@@ -28,6 +28,6 @@
28
28
  "prebuild": "rm -rf dist",
29
29
  "preversion": "npm run test && npm run build"
30
30
  },
31
- "version": "0.36.1",
32
- "gitHead": "032003a3354af0ad51cb539c6fc37e98697b77dc"
31
+ "version": "0.36.2",
32
+ "gitHead": "6bd9a56d67a2972248ed85a27e22f96d8577495a"
33
33
  }