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

Example: Link preloading (GET-only) #223

Closed
wants to merge 11 commits into from

Conversation

claudiodekker
Copy link
Member

@claudiodekker claudiodekker commented Sep 18, 2020

This functionality adds a 'request manager' of sorts, which has the following behavior:

  1. If there is no request, it starts the request and returns a promise that will eventually resolve (or fail)
  2. If the request is pending, it hooks a promise-resolver into the existing request, which will resolve (or fail) once completed.
  3. If the request has successfully finished, it returns a promise that instantly resolves to the (cached) request.
  4. If the prefetch request failed, it'll start a new request (see 1)

In all situations, in addition to the promise, you'll receive a cancel hook, so that if you want to cancel the individual visit.

This request manager has been implemented to pre-load GET requests on-hover (see https://instant.page/ for what it's supposed to do), as well as to cancel all 'pending' requests once the page switches.

Solves #45

This will allow us to make a call without running into prefetch response incompatibility issues.
We'll also move the cancelToken into an argument, so that the preloader can cancel any requests that are still preloading and are no longer relevant after a page transition.
This will allow the normal 'visit' to cancel the request after taking over.
@claudiodekker claudiodekker marked this pull request as draft September 18, 2020 11:36
@arondeparon
Copy link

Is this still being considered? Sounds like a great improvement!

@reinink reinink closed this Jul 28, 2023
@reinink
Copy link
Member

reinink commented Jul 28, 2023

Hey! Thanks so much for your interest in Inertia.js and for submitting this contribution.

In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.

Of course there's a chance that this PR is still relevant, and if that's the case feel free to re-submit it. If it's a new feature and not a bug fix maybe respond here first to make sure that it's something we want to include in the library.

Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️

@TheBlckbird
Copy link

@claudiodekker I think you could update this PR so it works with the current version of Inertia and re-submit it.

@TheBlckbird
Copy link

although I would use mousedown and not hover

@aarondfrancis
Copy link

Any chance we can pick this one back up? I really like Livewire's prefetching, it'd be nice to have it here too

@reinink
Copy link
Member

reinink commented Jul 19, 2024

Any chance we can pick this one back up? I really like Livewire's prefetching, it'd be nice to have it here too

It's something we're looking at for v2 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the core Inertia library enhancement New feature or request
Projects
Status: Closed 🚪
Development

Successfully merging this pull request may close these issues.

5 participants