The only advantage of 2-way data binding is called hype.
No, there is no real need of 2-way data binding, otherwise it would be invented and be part of Web Platform on a lower level long time ago.
Program should be simple, has one begin, one flow and one end.
When you need dynamic form updates, you make only these parts of your code dynamic. Usually you need to update whole form when user click Save button, it's a basic POST or AJAX POST request. In case of AJAX it's just few lines of JavaScript using Fetch API and DataForm API. Same goes with case where you need to update input instantly without clicking save what is popular today as well. I usually have own tiny Vanilla JS components I can apply on any form with few HTML code without writing JS at all. For example, it could be as easy as adding data-ajax attribute to <form> or specific input.
I recommend creating a Model object (API-speaking object) for each of your data models same way as on backend. I have my own Fetch wrapper in BunnyJS Api base object I use as blueprint for that.
const UserModel = Object.assign({}, Api, {
updateProfile(profileData) {
return this.post('/me/update-profile', profileData);
}
});
And in HTML I just specify which action should be called when Form is submitted
<form data-action="UserModel.updateProfile">
In my opinion not many, hence the explosion of popularity in React which enforces unidirectional data flow.
Source: my painful experience building large apps in Angular before React took over.
Atul Sharma
Full Stack Developer | Cloud Native Applications
I personally feel it saves a lot of boilerplate code which is needed to render data to view layer (HTML) . PS : It will only save your code and time when you are writing HTML and JavaScript separately in different files. (Angular 1, JQuery based applications).
but. if you are using front-end frameworks/ libraries likes React, Angular 2/4, there is no need of two way binding as you are writing html and js at the same place (Components) and that boilerplate code is automatically eliminated/reduced.
So, if you are using framework/ library where HTML and Js are separate two-way binding saves a lot of boilerplate code and work.. and if you code is way too much modular, componentized their is no need of two way binding.
It all depends on the requirement.
From performance perceptive in two-way binding , you need to setup un-necessary watchers / observables for every variable with consumes some sort of memory and running digest cycles (to check if variable is changed) in short spans definitely takes some toll on application's performance.