Skip to content

Commit 8fdb597

Browse files
small incremental changes
1 parent 818c972 commit 8fdb597

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

src/backend/tree.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Tree {
142142
const uniqueName = this.checkForDuplicates(name);
143143
// instantiate new sibilng tree with state, uniqueName, componentName and rtid
144144
const newSibling: Tree = new Tree(state, uniqueName, componentData, rtid);
145-
// updating newSibling parent to be the parent of "this" which refers to sibling node
145+
// updating newSibling's parent to be the parent of "this" which refers to sibling node
146146
newSibling.parent = this.parent;
147147
// adds newSibling to children array
148148
this.parent.children.push(newSibling);
@@ -160,27 +160,31 @@ class Tree {
160160
*/
161161
// if we havent made a copy of the tree, increment copyInstances and clear cicularComponentTable set
162162
if (copyInstances === 0) {
163+
// increment copyInstances
163164
copyInstances++;
165+
// clear circularComponentTable
164166
circularComponentTable.clear();
165167
}
166168
// creates copy of present node
167169
let copy: Tree = new Tree(this.state, this.name, this.componentData, this.rtid);
168-
// you want to get rid of the parentNode?? not sure why
170+
// you want to get rid of the parentNode becuase right now copy and "this" have the same parent and you dont want that
169171
delete copy.parent;
170172
// add to circularComponentTable
171173
circularComponentTable.add(this);
172-
//
174+
// remove unserializable Trees
173175
copy = scrubUnserializableMembers(copy);
174176

175-
// creates copy of each child of the present node
177+
// creates copy of each child of the present node and assigns it to children property of the new copy Tree
176178
copy.children = this.children.map((child: Tree): Tree | string => {
179+
// if child isnt in circularComponent table, return recursive call of cleanTreeCopy() on child. We need to do this to fully build out the tree
177180
if (!circularComponentTable.has(child)) {
178181
return child.cleanTreeCopy();
179182
}
180183
return 'circular';
181184
});
182-
185+
// reset copyInstances back to zero becuase we are done making a copy of the tree
183186
copyInstances--;
187+
// return the copy
184188
return copy;
185189
}
186190
}

src/backend/types/backendTypes.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@
44
import Tree from '../tree';
55

66
/**
7-
* The snapshot of the current tree
8-
* @param tree - {Tree} - The tree structure to send to front end
9-
* @param unfilteredTree - {null} - The current mode (i.e. jumping, time-traveling, or paused)
7+
* @type Tree - The snapshot of the current tree
8+
* @member tree - {Tree} - The tree structure to send to front end
9+
* @member unfilteredTree - {null} - The current mode (i.e. jumping, time-traveling, or paused)
1010
*/
1111
export interface Snapshot {
1212
tree: Tree;
1313
unfilteredTree: null;
1414
}
1515

1616
/**
17-
* Where we
18-
* @param jumping - whether we are jumping steps by
19-
* @param paused - true/false for whether pausing to see the state
17+
* @type Mode - object that describes where we are
18+
* @member jumping - whether we are jumping steps by
19+
* @member paused - true/false for whether pausing to see the state
2020
*/
2121
export interface Mode {
2222
jumping: boolean;
2323
paused: boolean;
2424
}
2525

2626
/**
27-
*
27+
* This is what is shown in developer tools??
28+
* @type SnapshotNode
29+
* @member name -
30+
* @member state -
31+
* @member children -
2832
*/
2933
export interface SnapshotNode {
3034
name: string;
@@ -34,7 +38,8 @@ export interface SnapshotNode {
3438
children: any[];
3539
}
3640
/**
37-
* @param data - an object with action & payload properties
41+
* @type MsgData - obj with data object that will be sent to window?
42+
* @member data - an object with action & payload properties
3843
*/
3944
export interface MsgData {
4045
data: {
@@ -44,14 +49,14 @@ export interface MsgData {
4449
}
4550

4651
/**
47-
*
48-
* @param index -
49-
* @param hooksIndex -
50-
* @param actualDuration -
51-
* @param actualStartTime -
52-
* @param selfBaseDuration -
53-
* @param treeBaseDuration -
54-
* @param props -
52+
* @type ComponentData -
53+
* @member index -
54+
* @member hooksIndex -
55+
* @member actualDuration -
56+
* @member actualStartTime -
57+
* @member selfBaseDuration -
58+
* @member treeBaseDuration -
59+
* @member props -
5560
*/
5661
export interface ComponentData {
5762
index?: number;
@@ -64,8 +69,9 @@ export interface ComponentData {
6469
}
6570

6671
/**
67-
* @param state -
68-
* @param component -
72+
* @type HookStateItem
73+
* @member state -
74+
* @member component -
6975
*/
7076
export interface HookStateItem {
7177
state: any;

0 commit comments

Comments
 (0)