Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance - Should two way data binding be avoided? [closed]

Sorry if the question is too basic.

I want to know if I should avoid two way data binding in my system. I can capture the values of the form in the submit the form without having to use two way data binding.

My question is whether the two way data binding actually consumes too much memory. Should I stop using it?

like image 349
Jobsdev Avatar asked Mar 08 '23 21:03

Jobsdev


1 Answers

Short answer: Yes, use it (in my opinion).

Performance wise, there was a problem with the way AngularJS (version 1) handled two way data binding, but this has been largely resolved in Angular 2+ (to the extent that its not something you need to concern yourself about in the vast majority of situations if at all).

It is however worth reading about how Angular handles 2 way binding because this will improve your understanding of the syntax and how you can use it to suit the context - Throughtram has a good blog on it here: https://blog.thoughtram.io/angular/2016/10/13/two-way-data-binding-in-angular-2.html

Whether it is "good practice" to use it, this is certainly debatable. While I agree that Denis Reshetniak's answer makes a valid point, I personally use it frequently and I would suggest that the time saved and greater simplicity of code more than makes up for any drawbacks and occasional issues you may run into (I've not had a problem yet and have been using it substantially since the version 2 release). At the end of the day, it depends on your situation and requirements - you should ensure you understand the pros and cons and then decide which approach suits your use case best.

like image 154
Steve Land Avatar answered Mar 24 '23 20:03

Steve Land