monk monk - 1 year ago 65
AngularJS Question

What is difference between two way data binding and reactivity?

As i follow some tuts for angular and ember.js I came across the term Two way data binding. Where data displayed on UI are bind with database and any changes to one is quickly propagated to the other. When I started learning meteor.js i came across term "Reactivity" which for me makes same sense as two way data binding. Can you please tell me fundamental difference between these two terms?

Answer Source

Reactivity is in fact more general the data binding. With reactivity you can implement data binding, in a really simple way, e.g.

var myAwesomeData = "some data";
var myAwseomeDependency = new Deps.Dependency();    

var getData = function () {
  return myAwesomeData;

var setData = function(value) {
  if (value !== myAwesomeData) {
    myAwesomeData = value;

Now, every time the getData routine is called within a computation, so basically within Deps.autorun environment, it gets recomputed. By default the meteor's collection API is implemented to be reactive, so every time fetch some data from you'r database you can be sure that it gets updated as soon as the data changes.

Also note, that you can also use the above reactivity schema without any data or database, so for example you can trigger and monitor events, states and so on.