components
components copied to clipboard
feat(SelectionModel): Add selectionCount or count property to SelectionModel
Feature Description
Add a new property named count or selectionCount to SelectionModel that returns the number of selected items. At the same time a countChanged event can be added.
Use Case
A count property in SelectionModel can reduce the array copies that the selected getter do or avoid the need to listen to selection changes in order to have the current state of the selection model. For example, A button to remove items only when an item is selected can be easily implemented with:
<button [disabled]="selectionModel.count === 0">
The a countChanged event, the button can react to changes instead. The current selection getter makes a defensible array copy and this generates overhead for a simple use case like this.