When Magento 2 creates a new constructor functions based on the uiElements
constructor functions, Magento 2 will often use a links
default
return Element.extend({
defaults: {
/* ... */
links: {
value: '${ $.provider }:${ $.dataScope }'
}
/* ... */
},
/* ... */
The links
property looks similar to the imports
and exports
feature, in that it uses template literals to create an identifier string.
{
value: 'checkoutProvider:shippingAddress.firstname'
}
When you (or Magento) use a links
value, you’re both importing and exporting the properties from the specified registry entry. If you’re not familiar with importing and exporting, you can read about them in the Magento 2: uiClass Data Features article, part of the UI Components series. The above value translates to the following uiRegistry
key
reg = requirejs('uiRegistry');
reg.get('checkoutProvider').shippingAddress.firstname;
For the curious, these links are setup in the following method
#File: vendor/magento/module-ui/view/base/web/js/lib/core/element/element.js
initLinks: function () {
return this.setListeners(this.listens)
.setLinks(this.links, 'imports')
.setLinks(this.links, 'exports')
.setLinks(this.exports, 'exports')
.setLinks(this.imports, 'imports');
},