platform icon indicating copy to clipboard operation
platform copied to clipboard

Lightweight layout on asynchronous loading

Open Augen2203 opened this issue 3 years ago • 0 comments

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 the query() 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. Снимок экрана 2022-02-09 в 00 16 06 Снимок экрана 2022-02-09 в 00 18 25

Augen2203 avatar Feb 08 '22 22:02 Augen2203