j-templates 8.0.4 → 8.0.5
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/Store/Tree/observableNode.js +0 -9
- package/Utils/emitter.js +18 -2
- package/package.json +1 -1
|
@@ -399,10 +399,6 @@ var ObservableNode;
|
|
|
399
399
|
}
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
|
-
// Assign every change before emitting any, so the diff lands atomically. Emitting per
|
|
403
|
-
// assignment let synchronous readers see partial states, e.g. an array's new length
|
|
404
|
-
// before its new elements were written.
|
|
405
|
-
// const updates = new Map<any, Set<string | number>>();
|
|
406
402
|
const pathTuples = [["", root]];
|
|
407
403
|
for (let x = 0; x < diffResult.length; x++) {
|
|
408
404
|
const { path, value } = diffResult[x];
|
|
@@ -424,12 +420,7 @@ var ObservableNode;
|
|
|
424
420
|
const assignValue = pathTuples[y][1];
|
|
425
421
|
assignValue[path[y]] = value;
|
|
426
422
|
ObservableNode.Update(assignValue, path[y]);
|
|
427
|
-
/* let props = updates.get(assignValue);
|
|
428
|
-
if (props === undefined) updates.set(assignValue, (props = new Set()));
|
|
429
|
-
props.add(path[y]); */
|
|
430
423
|
}
|
|
431
|
-
/* for (const [assignValue, props] of updates)
|
|
432
|
-
for (const prop of props) ObservableNode.Update(assignValue, prop as any); */
|
|
433
424
|
}
|
|
434
425
|
ObservableNode.ApplyDiff = ApplyDiff;
|
|
435
426
|
/**
|
package/Utils/emitter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Emitter = void 0;
|
|
4
|
+
const array_1 = require("./array");
|
|
4
5
|
const scheduling_1 = require("./scheduling");
|
|
5
6
|
const pendingCompactEmitters = new Set();
|
|
6
7
|
function Compact(emitter) {
|
|
@@ -39,9 +40,17 @@ var Emitter;
|
|
|
39
40
|
emitter.push(callback);
|
|
40
41
|
}
|
|
41
42
|
Emitter.On = On;
|
|
43
|
+
const emitterStack = [];
|
|
44
|
+
const modifiedDuringEmit = new Set();
|
|
42
45
|
function Emit(emitter, ...args) {
|
|
46
|
+
emitterStack.push(emitter);
|
|
43
47
|
for (let x = emitter[0] + 1; x < emitter.length; x++)
|
|
44
|
-
emitter[x](...args);
|
|
48
|
+
emitter[x]?.(...args);
|
|
49
|
+
emitterStack.pop();
|
|
50
|
+
if (modifiedDuringEmit.delete(emitter)) {
|
|
51
|
+
(0, array_1.RemoveNulls)(emitter);
|
|
52
|
+
emitter[0] = 0;
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
Emitter.Emit = Emit;
|
|
47
56
|
function Remove(emitter, callback) {
|
|
@@ -49,12 +58,19 @@ var Emitter;
|
|
|
49
58
|
return;
|
|
50
59
|
const startIndex = emitter[0] + 1;
|
|
51
60
|
const index = emitter.indexOf(callback, startIndex);
|
|
52
|
-
if (index
|
|
61
|
+
if (index < 1)
|
|
62
|
+
return;
|
|
63
|
+
const emitterStackIndex = emitterStack.indexOf(emitter);
|
|
64
|
+
if (emitterStackIndex < 0) {
|
|
53
65
|
emitter[0]++;
|
|
54
66
|
emitter[index] = emitter[startIndex];
|
|
55
67
|
emitter[startIndex] = null;
|
|
56
68
|
Compact(emitter);
|
|
57
69
|
}
|
|
70
|
+
else {
|
|
71
|
+
emitter[index] = null;
|
|
72
|
+
modifiedDuringEmit.add(emitter);
|
|
73
|
+
}
|
|
58
74
|
}
|
|
59
75
|
Emitter.Remove = Remove;
|
|
60
76
|
function Clear(emitter) {
|