You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/backend/linkFiber.ts
+31-28Lines changed: 31 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@ import {
28
28
importTreefrom'./tree';
29
29
// passes the data down to its components ?
30
30
importcomponentActionsRecordfrom'./masterState';
31
+
importroutesfrom'./routes';
31
32
32
33
// throttle returns a function that can be called any number of times (possibly in quick succession) but will only invoke the callback at most once every x ms
33
34
// getHooksNames - helper function to grab the getters/setters from `elementType`
* @class Route instances are created by the addRoute method on Routes. A Route instance has two properties: the url of the route and a unique id.
6
+
*/
7
+
classRoute{
8
+
url: string;
9
+
10
+
id: number;
11
+
12
+
constructor(url: string,id: number){
13
+
this.url=url;
14
+
this.id=id;
15
+
}
16
+
}
17
+
18
+
/**
19
+
* @class An instance of this class is the default export from routes.ts. It includes the logic that allows Reactime to work with target applications built with React Router. The addRoute method is invoked in linkFiber.ts within the sendSnapshot function. The navigate method is invoked in timeJump.ts immediately before invoking jump.
20
+
*/
21
+
22
+
classRoutes{
23
+
/**
24
+
* @property A stack of visited routes that matches the browser history stack.
25
+
*/
26
+
values: Route[]=[newRoute(null,null)];
27
+
28
+
/**
29
+
* @property Used to assign unique ids to routes in the values stack in case the same route is added to the stack more than once.
30
+
*/
31
+
id=0;
32
+
33
+
/**
34
+
* @property The index of the current route in the values stack.
35
+
*/
36
+
current: number|null=0;
37
+
38
+
/**
39
+
* @method addRoute
40
+
* @param url - A url string.
41
+
* @returns Either the current route if the user has not navigated away from it or a new instance of a route constructed from the url.
42
+
*
43
+
* Ensures that the values stack always matches the browser history stack.
44
+
*/
45
+
46
+
addRoute(url: string): Route{
47
+
letroute: Route=this.values[this.current];
48
+
49
+
if(this.values[this.current].url!==url){
50
+
if(this.current!==this.values.length-1){
51
+
this.rebuildHistory(url);
52
+
}
53
+
54
+
route=newRoute(url,(this.id+=1));
55
+
this.values.push(route);
56
+
57
+
this.current=this.values.length-1;
58
+
}
59
+
60
+
returnroute;
61
+
}
62
+
63
+
/**
64
+
* @method rebuildHistory
65
+
* @param url - A url string.
66
+
*
67
+
* Rebuilds the browser history stack using the copy of the stack maintained in the values stack. https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState, https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
Copy file name to clipboardExpand all lines: src/backend/tree.ts
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,8 @@ class Tree {
61
61
62
62
recoilDomNode: any;
63
63
64
+
route: {};
65
+
64
66
// Duplicate names: add a unique number ID
65
67
// Create an object 'componentNames' to store each component name as a key and it's frequency of use as its value
66
68
// When a new component is made on the tree, check if the new component's name already exists in 'componentNames' (possibly with the .hasOwnProperty method)
0 commit comments