forgo-state
Advanced tools
Comparing version 1.0.42 to 1.1.0
@@ -41,3 +41,6 @@ /* | ||
// concat latest updates with pending updates. | ||
const argsToUpdatePlusPendingArgs = argsToRenderInTheNextCycle.concat(argsListToUpdate.filter((x) => !argsToRenderInTheNextCycle.includes(x))); | ||
const argsToUpdatePlusPendingArgs = Array.from(new Set([ | ||
...Array.from(argsToRenderInTheNextCycle), | ||
...argsListToUpdate, | ||
])); | ||
const componentStatesAndArgs = argsToUpdatePlusPendingArgs.map((x) => { | ||
@@ -73,5 +76,4 @@ const state = getForgoState(x.element.node); | ||
}); | ||
argsToRenderInTheNextCycle.length = 0; | ||
for (const [, args] of componentsToUpdate) { | ||
argsToRenderInTheNextCycle.push(args); | ||
argsToRenderInTheNextCycle.add(args); | ||
} | ||
@@ -87,11 +89,16 @@ setTimeout(() => { | ||
} | ||
let argsToRenderInTheNextCycle = []; | ||
// We make this a Set because if rendering a component triggers another | ||
// forgo-state update we want to be sure we still finish updating everything we | ||
// had queued, plus everything the subrender enqueues | ||
const argsToRenderInTheNextCycle = new Set(); | ||
function doRender() { | ||
if (argsToRenderInTheNextCycle.length) { | ||
if (argsToRenderInTheNextCycle.size > 0) { | ||
for (const args of argsToRenderInTheNextCycle) { | ||
if (args.element.node && args.element.node.isConnected) { | ||
// Dequeue the component before the render, so that if the component | ||
// triggers more renders of itself they don't get no-op'd | ||
argsToRenderInTheNextCycle.delete(args); | ||
rerender(args.element); | ||
} | ||
} | ||
argsToRenderInTheNextCycle.length = 0; | ||
} | ||
@@ -98,0 +105,0 @@ } |
{ | ||
"name": "forgo-state", | ||
"version": "1.0.42", | ||
"version": "1.1.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -83,4 +83,7 @@ /* | ||
// concat latest updates with pending updates. | ||
const argsToUpdatePlusPendingArgs = argsToRenderInTheNextCycle.concat( | ||
argsListToUpdate.filter((x) => !argsToRenderInTheNextCycle.includes(x)) | ||
const argsToUpdatePlusPendingArgs = Array.from( | ||
new Set([ | ||
...Array.from(argsToRenderInTheNextCycle), | ||
...argsListToUpdate, | ||
]) | ||
); | ||
@@ -135,5 +138,4 @@ | ||
argsToRenderInTheNextCycle.length = 0; | ||
for (const [, args] of componentsToUpdate) { | ||
argsToRenderInTheNextCycle.push(args); | ||
argsToRenderInTheNextCycle.add(args); | ||
} | ||
@@ -154,12 +156,18 @@ | ||
let argsToRenderInTheNextCycle: ForgoRenderArgs[] = []; | ||
// We make this a Set because if rendering a component triggers another | ||
// forgo-state update we want to be sure we still finish updating everything we | ||
// had queued, plus everything the subrender enqueues | ||
const argsToRenderInTheNextCycle = new Set<ForgoRenderArgs>(); | ||
function doRender() { | ||
if (argsToRenderInTheNextCycle.length) { | ||
if (argsToRenderInTheNextCycle.size > 0) { | ||
for (const args of argsToRenderInTheNextCycle) { | ||
if (args.element.node && args.element.node.isConnected) { | ||
// Dequeue the component before the render, so that if the component | ||
// triggers more renders of itself they don't get no-op'd | ||
argsToRenderInTheNextCycle.delete(args); | ||
rerender(args.element); | ||
} | ||
} | ||
argsToRenderInTheNextCycle.length = 0; | ||
} | ||
@@ -166,0 +174,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24072
377