Skip to content

Check if there's a network request already in flight #79

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

Merged
merged 2 commits into from
Mar 31, 2022

Conversation

koddsson
Copy link
Contributor

@koddsson koddsson commented Mar 30, 2022

Make sure not to fire off additional requests if there's already one in-flight. I chose to reflect this on the element through the read-only busy attribute.

Fixes #75

@koddsson koddsson marked this pull request as ready for review March 30, 2022 15:03
@koddsson koddsson requested a review from a team as a code owner March 30, 2022 15:03
@koddsson koddsson requested a review from manuelpuyol March 30, 2022 15:03
@koddsson
Copy link
Contributor Author

This probably needs a failing test before the fix commit.

Base automatically changed from refactor to main March 30, 2022 15:55
Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

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

Seems reasonable. Is it instead better to use AbortControllers to close previous requests, so that we always use the latest request?

@koddsson
Copy link
Contributor Author

Seems reasonable. Is it instead better to use AbortControllers to close previous requests, so that we always use the latest request?

Yeah, I think we could. I wanted to avoid doing multiple requests altogether though since I thought that was an error in itself.

@koddsson
Copy link
Contributor Author

koddsson commented Mar 31, 2022

Seems reasonable. Is it instead better to use AbortControllers to close previous requests, so that we always use the latest request?

Yeah, I think we could. I wanted to avoid doing multiple requests altogether though since I thought that was an error in itself.

I was gonna do this but then we still emit the event twice because #getData still fetches data from the WeakMap and we happily emit the event.

I think we can refactor more in this component to make something like that easier but that would probably result in a breaking change.

@koddsson koddsson merged commit c405e3a into main Mar 31, 2022
@koddsson koddsson deleted the check-if-network-request-is-already-in-flight branch March 31, 2022 14:55
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.

include-fragment-replaced triggered twice
2 participants