Skip to content
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

Merged
merged 3 commits into from
Jan 29, 2019

Conversation

frehner
Copy link
Member

@frehner frehner commented Jan 29, 2019

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.

}
return app
})
}
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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

Anthony Frehner added 2 commits January 29, 2019 12:41
…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];
Copy link
Contributor

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.

Copy link
Contributor

@TheMcMurder TheMcMurder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐙

@frehner frehner merged commit 59bf4f7 into master Jan 29, 2019
@frehner frehner deleted the devtools-1 branch January 29, 2019 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants