You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
An important change has been shipped for the view models in Magento 2.3.2 and is missing in the release notes.
Now the instances of the view models are shared by default. If a view model requires to be a new instance at each time, you have to add the attribute shared="false" on the argument node in the layout xml file.
Eg:
<block class="Magento\Framework\View\Element\Template" name="block.one">
<arguments>
<argument name="dataSource" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Toto\Collection</argument><!-- is a new instance -->
<argument name="dataProvider" xsi:type="object">Vendor\Module\ViewModel\DataProvider</argument><!-- is instantiate first here -->
</arguments>
</block>
<block class="Magento\Framework\View\Element\Template" name="block.two">
<arguments>
<argument name="dataSource" xsi:type="object" shared="false">Vendor\Module\Model\ResourceModel\Toto\Collection</argument><!-- is a new instance -->
<argument name="dataProvider" xsi:type="object">Vendor\Module\ViewModel\DataProvider</argument><!-- is the same instance as in block.one -->
</arguments>
</block>
Incompatible Backward change
Description
An important change has been shipped for the view models in Magento 2.3.2 and is missing in the release notes.
Now the instances of the view models are shared by default. If a view model requires to be a new instance at each time, you have to add the attribute shared="false" on the argument node in the layout xml file.
Eg:
See PR: magento/magento2#18541
The text was updated successfully, but these errors were encountered: