-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Lightweight layout on asynchronous loading #2120
base: master
Are you sure you want to change the base?
Conversation
src/Screen/Layout.php
Outdated
}) | ||
->collapse() | ||
->all(); | ||
if (!$this->asyncMethod || ($this->asyncMethod && $this->async)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good idea. But let's put it in a separate method:
protected function reparation(): array
{
if (...) {
return [];
}
return collect($this->layouts)->...;
}
What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
Yes, this is a good idea, thanks to this, the logic will be simplified and the code will become more readable.
I'm sorry, I use a modified version of the package at home, and sometimes I forget about the paths for the package
*/ | ||
protected function reparation(): array | ||
{ | ||
if ($this->asyncMethod && !$this->async) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During testing, I found that if we use asynchronous form loading and subsequently receive an error related to validation in it, it will not be displayed to us, since our asynchronous layout will not initially be loaded when the screen loads.
This error will be eliminated by adding an additional check.
if ($this->asyncMethod && !$this->async && !Session::get('errors')) {...
But in this case, again the null related error I mentioned earlier may occur.
For example, if you use something like:
$this->query->get('user')->exists
in our layout, since in case of receiving a validation error, we return to the past logic of behavior
Hello, this corrects the following points:
Speeds up screen loading by not rendering empty layouts, which are subsequently replaced by an async request.
We no longer need to predefine properties in the
query()
method that are equal to those that we would use in asynchronously loaded layouts.In my particular case, when I use a lot of async modals, this gave me some pluses, in terms of memory, the number of layouts loaded and speed.