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

Remove async data implementation #10896

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

codyrancher
Copy link
Contributor

@codyrancher codyrancher commented Apr 29, 2024

Summary

Removing asyncData references and unused hot module reload code

Technical notes summary

While removing references to asyncData I noticed that the HMR code used for calling both asyncData and fetch were not actually being used on code changes. This lead me to deleting the HMR code as well. We can split this PR up into two separate if we deem necessary.

Areas or cases that should be tested

asyncData has already been removed so that area shouldn't be affected. We should verify that HMR still works for usages of fetch.

Screenshot/Video

remove-unused-hmr.mp4

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

@codyrancher codyrancher added this to the v2.9.0 milestone Apr 29, 2024
Comment on lines -489 to -492
// Hot reloading
if (isDev) {
setTimeout(() => hotReloadAPI(this), 100);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned in the PR summary. I noticed that the HMR code wasn't actually being used so I decided to remove it for both fetch and asyncData.

The video I posted demonstrates that HMR was still working in fetch even without this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL

@@ -505,108 +478,6 @@ function nuxtReady(_app) {
}
}

const noopData = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This entire section is for the HMR of fetch and asyncData

this.error();
const promises = [];
const next = function(path) {
this.$loading.finish && this.$loading.finish();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes me wonder if $loading can be removed entirely. I didn't experience any regressions while clicking through the app in dev.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean for this specific case or in general?

@@ -72,34 +72,6 @@ export function getChildrenComponentInstancesUsingFetch(vm, instances = []) {
return instances;
}

export function applyAsyncData(Component, asyncData) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All invocations of this were removed.

@codyrancher codyrancher marked this pull request as ready for review April 29, 2024 18:22
@codyrancher codyrancher changed the title Remove async data impl Remove async data implementation Apr 29, 2024
Copy link
Member

@rak-phillip rak-phillip left a comment

Choose a reason for hiding this comment

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

LGTM - I played around with different scenarios to see if I could trigger some unexpected behavior (managing extensions, mocking development, provisioning clusters, reloading pages, etc...) and I'm unable to find anything wrong with this.

I'm quite glad to see a lot of this code go 😁

Comment on lines 273 to 277
Components.forEach((Component) => {
if (Component._Ctor && Component._Ctor.options) {
Component.options.asyncData = Component._Ctor.options.asyncData;
Component.options.fetch = Component._Ctor.options.fetch;
}
});
Copy link
Member

@rak-phillip rak-phillip Apr 29, 2024

Choose a reason for hiding this comment

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

Based on your other comment about HMR1, would we be able to drop this (fetch) as well?

Footnotes

  1. https://github.com/rancher/dashboard/pull/10896/files#r1583518001

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might be able to but I haven't verified yet. It wasn't as obvious while I was digging. I'll take a look and open a separate PR if we can.

@codyrancher codyrancher merged commit 943445a into rancher:master Apr 29, 2024
33 checks passed
Copy link
Contributor

@cnotv cnotv left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines -489 to -492
// Hot reloading
if (isDev) {
setTimeout(() => hotReloadAPI(this), 100);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

LOL

this.error();
const promises = [];
const next = function(path) {
this.$loading.finish && this.$loading.finish();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean for this specific case or in general?

@codyrancher
Copy link
Contributor Author

Do you mean for this specific case or in general?
I meant in general. I've looked at it's not quite possible to remove $loading yet. We can remove some of the methods invoked on it though.

$loading is actually assigned a reference to a component (our loading component) and then these are invocations on that component.

@codyrancher codyrancher mentioned this pull request Apr 30, 2024
7 tasks
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

3 participants