forgo-state
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -10,2 +10,3 @@ "use strict"; | ||
const entries = stateMap.get(proxy); | ||
// if bound to the state directly, add for updation on any state change. | ||
const argsForUncheckedUpdation = entries | ||
@@ -16,2 +17,3 @@ ? entries | ||
: []; | ||
// Get the props before update | ||
let propsToCompare = entries | ||
@@ -26,2 +28,3 @@ ? entries | ||
target[prop] = value; | ||
// Get the props after update | ||
let updatedProps = entries | ||
@@ -35,7 +38,11 @@ ? entries | ||
: []; | ||
// concat state based updates and props based updates | ||
const argsListToUpdate = argsForUncheckedUpdation.concat(propsToCompare | ||
.filter((oldProp, i) => oldProp.props.some((p, j) => p !== updatedProps[i].props[j])) | ||
.map((x) => x.args)); | ||
// concat latest updates with pending updates. | ||
const argsToUpdatePlusPendingArgs = argsListToUpdate.concat(argsToRenderInTheNextCycle); | ||
// make a map, of node => all args attached to node | ||
const argsListMap = new Map(); | ||
for (const args of argsListToUpdate) { | ||
for (const args of argsToUpdatePlusPendingArgs) { | ||
if (args.element.node) { | ||
@@ -50,2 +57,5 @@ let entry = argsListMap.get(args.element.node); | ||
} | ||
// Now for each node, find the args with the lowest componentIndex | ||
// Rendering the component with the lowest componentIndex | ||
// The higher up components get rendered automatically. | ||
const argsListWithMinComponentIndex = []; | ||
@@ -70,9 +80,9 @@ for (const entries of argsListMap) { | ||
} | ||
// If we're rendering a parent node, skip the descendent nodes. | ||
// Now we gotta find if a node is a child of another node pending rerender | ||
// If so, there's no need to render the descendant node. | ||
const justTheNodes = argsListWithMinComponentIndex | ||
.map((x) => x.element.node) | ||
.filter((x) => x); | ||
const argsListOfParentNodes = argsToRenderInTheNextCycle | ||
.concat(argsListWithMinComponentIndex) | ||
.filter((x) => !justTheNodes.some((y) => y !== x.element.node && y.contains(x.element.node))); | ||
const argsListOfParentNodes = argsListWithMinComponentIndex.filter((arg) => !justTheNodes.some((node) => node !== arg.element.node && node.contains(arg.element.node))); | ||
argsToRenderInTheNextCycle.length = 0; | ||
for (const args of argsListOfParentNodes) { | ||
@@ -99,3 +109,3 @@ argsToRenderInTheNextCycle.push(args); | ||
} | ||
argsToRenderInTheNextCycle = []; | ||
argsToRenderInTheNextCycle.length = 0; | ||
} | ||
@@ -102,0 +112,0 @@ } |
{ | ||
"name": "forgo-state", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "./dist", | ||
@@ -5,0 +5,0 @@ "author": "Jeswin Kumar<jeswinpk@agilehead.com>", |
@@ -28,2 +28,3 @@ import { | ||
// if bound to the state directly, add for updation on any state change. | ||
const argsForUncheckedUpdation: ForgoRenderArgs[] = entries | ||
@@ -35,2 +36,3 @@ ? entries | ||
// Get the props before update | ||
let propsToCompare = entries | ||
@@ -47,2 +49,3 @@ ? entries | ||
// Get the props after update | ||
let updatedProps = entries | ||
@@ -57,2 +60,3 @@ ? entries | ||
// concat state based updates and props based updates | ||
const argsListToUpdate = argsForUncheckedUpdation.concat( | ||
@@ -66,5 +70,11 @@ propsToCompare | ||
// concat latest updates with pending updates. | ||
const argsToUpdatePlusPendingArgs = argsListToUpdate.concat( | ||
argsToRenderInTheNextCycle | ||
); | ||
// make a map, of node => all args attached to node | ||
const argsListMap = new Map<ChildNode, ForgoRenderArgs[]>(); | ||
for (const args of argsListToUpdate) { | ||
for (const args of argsToUpdatePlusPendingArgs) { | ||
if (args.element.node) { | ||
@@ -80,2 +90,5 @@ let entry = argsListMap.get(args.element.node); | ||
// Now for each node, find the args with the lowest componentIndex | ||
// Rendering the component with the lowest componentIndex | ||
// The higher up components get rendered automatically. | ||
const argsListWithMinComponentIndex: ForgoRenderArgs[] = []; | ||
@@ -103,3 +116,4 @@ | ||
// If we're rendering a parent node, skip the descendent nodes. | ||
// Now we gotta find if a node is a child of another node pending rerender | ||
// If so, there's no need to render the descendant node. | ||
const justTheNodes = argsListWithMinComponentIndex | ||
@@ -109,12 +123,11 @@ .map((x) => x.element.node) | ||
const argsListOfParentNodes = argsToRenderInTheNextCycle | ||
.concat(argsListWithMinComponentIndex) | ||
.filter( | ||
(x) => | ||
!justTheNodes.some( | ||
(y) => | ||
y !== x.element.node && y.contains(x.element.node as ChildNode) | ||
) | ||
); | ||
const argsListOfParentNodes = argsListWithMinComponentIndex.filter( | ||
(arg) => | ||
!justTheNodes.some( | ||
(node) => | ||
node !== arg.element.node && node.contains(arg.element.node as ChildNode) | ||
) | ||
); | ||
argsToRenderInTheNextCycle.length = 0; | ||
for (const args of argsListOfParentNodes) { | ||
@@ -146,3 +159,3 @@ argsToRenderInTheNextCycle.push(args); | ||
} | ||
argsToRenderInTheNextCycle = []; | ||
argsToRenderInTheNextCycle.length = 0; | ||
} | ||
@@ -149,0 +162,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
23333
365