DEV Community

Discussion on: NgRx Selector Performance

scooperdev profile image
Stephen Cooper Author

I am not 100% clear which function you are referring to that is receiving the array? If its the selector then yes if it results in a new array or a different reference then it will fire a new value. I would argue that if the array is changing then it should be recalculated. If its within our control then we should check that we are not updating the array references when we know its contents will not be changing.

If that is outside of our control then we would have to decide what is more performant. To apply a custom distinctUntilChanged to the selector or just run the calculation again.

And yes I totally agree this is overkill for adding 2 numbers! I tried to make that clear in the post and that this technique is only required when you are running expensive computations based off your state.