uiCollection class

The uiCollection library class should be used as a base class by any components that contain a collection of child UI components. uiCollection inherits from the uiElement class.

uiCollection source code is <Magento_Ui_module_dir>/view/base/web/js/lib/core/collection.js, in the Magento Open Source GitHub repository: app/code/Magento/Ui/view/base/web/js/lib/core/collection.js.

Commonly used methods

The uiCollection class implements the following methods:

Example:

this.destroy();

Example:

this.getChild(childIndex)

where childIndex is the value of the child element's index property.

Commonly used properties

Template

The uiCollection template is <Magento_Ui_module_dir>/view/base/web/templates/collection.html, in the Magento Open Source GitHub repository: app/code/Magento/Ui/view/base/web/templates/collection.html.

This template performs only one task: renders child templates if they exist.

It looks like following:

<each args="data: elems, as: 'element'">
    <render if="hasTemplate()"/>
</each>

Here elems is the collection of the child elements of uiCollection. As far as elems is the observable property, the templates of the components added to elems in the runtime, are also rendered.