Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

immutable filter selected items #483

Open
djleonskennedy opened this issue Sep 28, 2016 · 1 comment
Open

immutable filter selected items #483

djleonskennedy opened this issue Sep 28, 2016 · 1 comment

Comments

@djleonskennedy
Copy link

djleonskennedy commented Sep 28, 2016

Hello

Have situation where i need to filter items when item removed

function remove(id) {
   vm.items = vm.items.filter(item => item.id === id)
}

but also i have items selected so i should update it as

function remove(id) {
   vm.items = vm.items.filter(item => item.id === id)
   vm.selected = vm.selected.filter(item => item.id === id) // from table model
}

and it works, but one thing isn't
i have counter of selected

vm.all = vm.selected.length;

and after filtering of selected items all references are destroyed cause filter return new array (as you know).
i can use splice to mutate vm.selected, but i need immutable solution

can we do it in immutable way?

Thank you

@djleonskennedy
Copy link
Author

djleonskennedy commented Oct 23, 2016

could be fixed in #403

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant