j-templates 7.0.82 → 7.0.84
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.
|
@@ -143,6 +143,9 @@ function RegisterEmitter(emitter) {
|
|
|
143
143
|
case SAME_STRATEGY:
|
|
144
144
|
RegisterSame(watchState, emitter);
|
|
145
145
|
break;
|
|
146
|
+
case INIT_STRATEGY:
|
|
147
|
+
watchState.emitters = [];
|
|
148
|
+
watchState.strategy = PUSH_STRATEGY;
|
|
146
149
|
case PUSH_STRATEGY:
|
|
147
150
|
RegisterPush(watchState, emitter);
|
|
148
151
|
break;
|
|
@@ -177,9 +180,10 @@ function GetScopeValue(scope) {
|
|
|
177
180
|
* Each strategy represents a different approach to tracking and deduplicating dependencies.
|
|
178
181
|
*/
|
|
179
182
|
const SAME_STRATEGY = 1;
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
+
const INIT_STRATEGY = 2;
|
|
184
|
+
const PUSH_STRATEGY = 3;
|
|
185
|
+
const DISTINCT_STRATEGY = 4;
|
|
186
|
+
const SHRINK_STRATEGY = 5;
|
|
183
187
|
let watchState = null;
|
|
184
188
|
/**
|
|
185
189
|
* Executes a callback while tracking all scope and emitter dependencies.
|
|
@@ -193,11 +197,11 @@ function WatchFunction(callback, currentCalc, initialEmitters) {
|
|
|
193
197
|
watchState = {
|
|
194
198
|
emitterIndex: 0,
|
|
195
199
|
value: null,
|
|
196
|
-
emitters: initialEmitters
|
|
200
|
+
emitters: initialEmitters,
|
|
197
201
|
emitterSet: null,
|
|
198
202
|
currentCalc,
|
|
199
203
|
nextCalc: null,
|
|
200
|
-
strategy: initialEmitters === null ?
|
|
204
|
+
strategy: initialEmitters === null ? INIT_STRATEGY : SAME_STRATEGY,
|
|
201
205
|
};
|
|
202
206
|
watchState.value = callback();
|
|
203
207
|
const resultState = watchState;
|
|
@@ -294,6 +298,8 @@ function CalcScope(callback, idOverride) {
|
|
|
294
298
|
* @param distinct Whether emitters are already unique (sorted and deduplicated).
|
|
295
299
|
*/
|
|
296
300
|
function UpdateEmitters(scope, state) {
|
|
301
|
+
if (state.strategy === INIT_STRATEGY)
|
|
302
|
+
return;
|
|
297
303
|
if (scope.emitters === null) {
|
|
298
304
|
for (let x = 0; x < state.emitters.length; x++)
|
|
299
305
|
emitter_1.Emitter.On(state.emitters[x], scope.setCallback);
|
|
@@ -343,10 +349,9 @@ function DestroyAllScopes(scopes) {
|
|
|
343
349
|
function DestroyScope(scope) {
|
|
344
350
|
if (!scope || scope.type === "static")
|
|
345
351
|
return;
|
|
346
|
-
|
|
352
|
+
emitter_1.Emitter.Clear(scope.emitter);
|
|
347
353
|
for (const key in scope.calcScopes)
|
|
348
354
|
DestroyScope(scope.calcScopes[key]);
|
|
349
|
-
scope.calcScopes = null;
|
|
350
355
|
for (let x = 0; x < scope.emitters.length; x++)
|
|
351
356
|
emitter_1.Emitter.Remove(scope.emitters[x], scope.setCallback);
|
|
352
357
|
scope.value = undefined;
|