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
Added comments to routes.ts. Reverted previous change saveNew in masterState that is no longer relevant. Made accompanying changes in linkFiber and backendTypes.
Copy file name to clipboardExpand all lines: src/backend/routes.ts
+39-1Lines changed: 39 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
/* eslint-disable max-classes-per-file */
2
+
/* eslint-disable max-len */
2
3
4
+
/**
5
+
* @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
+
*/
3
7
classRoute{
4
8
url: string;
5
9
@@ -11,13 +15,34 @@ class Route {
11
15
}
12
16
}
13
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
+
14
22
classRoutes{
23
+
/**
24
+
* @property A stack of visited routes that matches the browser history stack.
25
+
*/
15
26
values: Route[]=[newRoute(null,null)];
16
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
+
*/
17
31
id=0;
18
32
33
+
/**
34
+
* @property The index of the current route in the values stack.
35
+
*/
19
36
current: number|null=0;
20
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
+
21
46
addRoute(url: string): Route{
22
47
letroute: Route=this.values[this.current];
23
48
@@ -35,7 +60,13 @@ class Routes {
35
60
returnroute;
36
61
}
37
62
38
-
rebuildHistory(url: string): void{
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
0 commit comments