vendredi 27 février 2015

replacing angular deep watcher


I have this data object called fulldata, which is an array of objects.



fulldata = [
{'key': 'abc', values: {.....},....},
{'key': 'efg', values: {.....},....},
{'key': 'hij', values: {.....},....},
.....]


this data is used to display charts using D3, and the keys of the objects represent the legend of the chart. Each time user enters a chart, the object is added to fulldata. Now if the values property of the objects changes(due to various user actions), i will have to re render the chart accordingly but if only the key changes, I just need to update the legend.


I tried deep watching the entire fulldata and change only the legend if key is changed based on a conditional. It works fine but the application is very slow because the values property is a very huge data set.


I tried making a separate function getKeys() to get all the keys and watch that function but its throwing me an error saying "Error:10 $digest() iterations reached. Aborting!"


Is there anything else I can try to accomplish what i want with a better performance than deep watching? If anyone has an idea or has encountered similar issue, please help. Thanks.





Aucun commentaire:

Enregistrer un commentaire