Skip to content

Commit b5e6763

Browse files
committed
removed snapshot node, comments on deprecated pushstate, code and comments from LA 45 cohort with some deprecated non-functioning hover cases, Added comment for regenerator runtime, comments for what linkfiber and timejump do, comments to linkfiber to provide more documentation on code flow
1 parent 8b0791d commit b5e6763

File tree

1 file changed

+9
-40
lines changed

1 file changed

+9
-40
lines changed

src/backend/index.ts

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* 'reactime' module has a single export
88
* @function linkFiber
99
*/
10-
10+
// regenerator runtime supports async functionality
1111
import 'regenerator-runtime/runtime';
1212
import linkFiberStart from './linkFiber';
1313
import timeJumpStart from './timeJump';
1414
import {
15-
Snapshot, Mode, SnapshotNode, MsgData,
15+
Snapshot, Mode, MsgData,
1616
} from './types/backendTypes';
1717

1818
// * State snapshot object initialized here
@@ -26,57 +26,26 @@ const mode: Mode = {
2626
paused: false,
2727
};
2828

29+
// linkFiber is now assigned the default function exported from the file linkFiber.ts
2930
const linkFiber = linkFiberStart(snapShot, mode);
31+
// timeJump is now assigned the default function exported from the file timeJump.ts
3032
const timeJump = timeJumpStart(snapShot, mode);
3133

3234
// * Event listener for time-travel actions
3335
window.addEventListener('message', ({ data: { action, payload } }: MsgData) => {
3436
switch (action) {
3537
case 'jumpToSnap':
36-
timeJump(payload, true); // * This sets state with given payload
37-
// Get the pathname from payload and add new entry to browser history
38-
// MORE: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
39-
// try to modify workInProgress tree from here
40-
// window.history.pushState('', '', getRouteURL(payload));
38+
timeJump(payload, true); // * This sets state with given payloa
4139
break;
40+
4241
case 'setPause':
4342
mode.paused = payload;
4443
break;
45-
// maybe this isn't work react cohort 45
46-
// case 'onHover':
47-
// if (Array.isArray(payload)) {
48-
// for (let i = 0; i < payload.length; i + 1) {
49-
// const element = document.getElementById(payload[i]);
50-
// if (element !== null) {
51-
// element.style.backgroundColor = '#C0D9D9';
52-
// }
53-
// }
54-
// } else {
55-
// const element: HTMLElement = document.querySelector(`.${payload}`);
56-
// if (element !== null) {
57-
// element.style.backgroundColor = '#C0D9D9';
58-
// }
59-
// }
60-
// break;
61-
// // maybe this isn't work react cohort 45
62-
// case 'onHoverExit':
63-
// if (Array.isArray(payload)) {
64-
// for (let i = 0; i < payload.length; i++) {
65-
// const element: HTMLElement = document.querySelector(`.${payload}`);
66-
// if (element !== null) {
67-
// element.style.backgroundColor = '';
68-
// }
69-
// }
70-
// } else {
71-
// const element: HTMLElement = document.querySelector(`.${payload}`);
72-
// if (element !== null) {
73-
// element.style.backgroundColor = '';
74-
// }
75-
// }
76-
// break;
44+
7745
default:
7846
break;
7947
}
8048
});
81-
// connect to dev tools and new fiber
49+
// connect to dev tools and new fiber,
50+
// invokes anonymous function from linkFiber.ts set to linkFiber on line 30
8251
linkFiber();

0 commit comments

Comments
 (0)