-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
feat: support nested and wildcard only
props
#435
Conversation
only
propsonly
props
Why is that? Can the implementation be simplified using Laravel's |
Because if you implement a modal you usually need a lazy prop [
"modal" => Inertia::lazy(fn () => [
"someData" => "Foo",
"lazyProp" => Inertia::lazy(fn () => "abc"),
])
] And request the modal with, Which is impossible to do with the current implementation, the nested lazy prop will always be evaluated if you request It couldn't be simplified with `Arr::dot` and `Arr::undot` for one simple reason, you'd have to evaluate lazy props before if you want to flatten it in a nested manner and run that on itArr::dot([
"modal" => Inertia::lazy(fn () => [
"someData" => "Foo",
"lazyProp" => Inertia::lazy(fn () => "abc"),
])
]);
// Will just return
[
"modal" => Inertia::lazy(fn () => [
"someData" => "Foo",
"lazyProp" => Inertia::lazy(fn () => "abc"),
])
]
// So back to square 1 it would also perform 100 times worse as you need to perform the flattening and unflattening on the props recursively which could very well have a 10 000 elements especially if you share models with relations instead of the "only" value which is usually only 1-3 elements, you also run the risk of loosing elements (I don't know if Arr::dot preserves empty arrays) but it's overall not a good idea, you really want to work with a tree and evaluate as you traverse for this kind of value visiting If you mean I can give it a try and see if it doesn't break the tests I made |
Gave it a try and yes, the issue is that Because it either results in |
Native nested lazy props would be really handy for us, allowing nested dynamic prop registration from other 1st party PHP packages, without polluting the root page props object. |
Heya. We removed our master branch. Feel free to re-attempt this to 1.x! |
@Tofandel yes please! This is definitely needed. Greatly appreciating your work towards a glory revival of Inertia! Waiting for this for quite some time and going to use it in combination with lepikhinb/momentum-modal#18 👏 |
@onlime Then please feel free to take over my PR on 1.x, keeping in mind that half of the feature has been shipped already #620 I have completely switched from inertia to hybridly (like inertia but much better) due to my complete dissatisfaction with maintenance, lack of progress and disregard for contributors on inertia (I opened about 6 PRs which took several days to make, none of which were ever as much as reviewed and because of the multiple force push it has become impossible to work with and of course I'm only a needle in the haystack of contributors that have the same stories) I will not spend any more wasted time on inertia after this debacle |
This PR adds support for lazy props at any level and retrieving partial data at any depth
Eg:
only: ['modal.props.aLazyProp']
oronly: ['allNestedLazyProps.*']
There is support for 2 type of wildcards
It's a necessary feature if we want to implement modals and such and very useful for improving performances of very complex pages with a lot of data
Goes by par with inertiajs/inertia#1247