Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recreating this PR due to the master branch deletion. If the previous PR was closed on purpose, I apologize for the noise.
Original description: I felt inspired by Livewire 3 Lazy feature which automatically fetched the data on page load. I think there's a ton of value in Inertia's current Lazy prop feature, but I think there are also scenarios where adding a Defer prop feature which automatically loads Lazy data on page load.
This works in tandem with inertiajs/inertia#1617. It works by extending the Lazy feature but also informs the front-end on page load which deferred properties should be loaded automatically. These properties will then automatically trigger a reload with those properties automatically added in the
only
attribute.This reduces the amount of front-end code required to pull this off. To add a long-running API query to be deferred, it would look like this:
These deferred properties will only ever be loaded automatically after page loads/navigations. Otherwise, they behave just the same as Lazy props.