Preloading Entities
At load time, views are scanned for scenario and entity references—such references are collated and network requests for data batched together in a preload step.
Views are hidden behind a loading spinner image until data is available, resulting in more optimal data fetching and less UI flicker.
It is not always possible for the VDL engine to determine all scenario and entity usage until the preload step has completed and the UI is partially rendered. The view will still function correctly, as the data will be requested on demand. However, this situation is not optimal.
When entity data is fetched on demand after the preload step, a [VDL HINT] is logged in the console. It identifies the scenario and entity being requested and offers a generated VDL snippet you can add to your VDL code to include in the preload step using the <vdl-preload> element.
You can also manually specify entities, parameters, or attachments to be preloaded for one or more scenarios using the
<vdl-preload> element. This example preloads the entities
myBool and
intArray for the second scenario only:
<vdl-preload entities="MyBool,IntArray" scenarios="1"></vdl-preload>Replace scenarios="1" with scenarios="all" to preload the entities for all scenarios.
To preload all parameters for all scenarios:
<vdl-preload load-parameters="true" scenarios="all"></vdl-preload>The final example preloads all attachment metadata for the second scenario:
<vdl-preload load-attachments="true" scenarios="1"></vdl-preload>