I never really understood the point of binding, beyond it being effectively shorthand for addeventlistener.
is there more to it? am I missing something?
thanks,
dsdsdsdsd
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Data binding is all about declaratively defining how data is displayed in the UI. Under the hood, it is a bit more complicated, because there are more needs than just hooking
addEventListenerto support the features of data binding.It is a very powerful feature, actually, and to understand it more, we can look at a simple “Hello World” application:
Now, compile this app with the
--keepcompiler flag and look at the new folder “bin-debug/generated”. We are interested in HelloWorld-generated.asHere is where that binding gets defined and called from the constructor:
A little later, in the HelloWorld constructor, you get a call to set up the watchers:
Which really just does this:
Things get more complicated with two-way bindings.