platform
platform copied to clipboard
Lightweight layout on asynchronous loading
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.
Previously, for example, this was necessary if we used the
canSee()method, like so:
->canSee($this->query->get('user')->exists).
Example:
We have an asynchronous modal window to which we pass the user model through the asyncGetUser() method, in this modal window there is a layout with a form in which, depending on whether the user exists or not, we want to hide one of the fields through a function
->canSee($this->query->get('user')->exists).We'll get an error because when the screen first loads,
$this->query->get('user')will be null, Therefore, as one of the options, we needed to predefine it in thequery()method, thus:public function query(User $user) { return [ 'user' => $user ]; }
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.
