Let's say I have some data from a service call, and I store it as originalData.
Now in addition, I must filter the data and also display that filtered data. The way I'm doing that is like this:
this.service.getData((data) => {
this.originalData = data;
this.filteredData = data.filter(/* some filter condition */);
});
I have originalData and filteredData bound on the html template. This solution works. As I require more and more of the filtered versions to be displayed, so I'm storing more and more of these filtered or otherwise modified objects on my class.
This seems like a bad practice, as the state of my class is increasing and getting out of control, and managing the different copies of the data is getting cumbersome.
What would a better practice be?