-
-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial work on adding hooks into single-spa for devtools functionality #266
Conversation
src/devtools/devtools.helper.js
Outdated
} | ||
return app | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong here, IIRC because app is an object it's passed by reference. Meaning this delete methods are going to modify the actual app instead of modifying a duplicate of the app
src/devtools/devtools.helper.js
Outdated
@@ -0,0 +1,22 @@ | |||
export function removeCyclicReferences(apps) { | |||
// we must get rid of cyclic references before we can return apps -- otherwise, devtools gets an error because JSON.stringify doesn't resolve cyclic references |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does devTools need to stringify the apps? React Components are also circular, what are they doing differently (or are they doing the same thing)
I'm not sure I fully understand why this is necessary
…an just remove the cyclical referernces altogether, and rely on the closures that already exist.
@@ -15,6 +15,11 @@ export function getAppNames() { | |||
return apps.map(toName); | |||
} | |||
|
|||
// used in devtools, not (currently) exposed as a single-spa API | |||
export function getRawAppData() { | |||
return [...apps]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have some worry about exposing the full internal representation to the dev tools, because we can't call the methods on them anyways, I'm still interested in these values being a copy of the internal representation long term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐙
Devtools need raw app info, so I had to add that function
Since the data being passed between devtools and the inspected window is JSON.stringify-ed, cyclic references break that process. So to clean up the apps array for that, we have to remove those cyclic references.