How does rxjs observable perform compare to $watch in Angularjs 1.X? How does rxjs observable perform compare to $watch in Angularjs 1.X? angularjs angularjs

How does rxjs observable perform compare to $watch in Angularjs 1.X?


The two mechanisms of observing changes are inherently different.

$watch is a brute force, pull-based mechanism. Where the observer is active and (generally) needs to visit each observed object / expression after any change happened. Surely the more to observe the slower the whole process.

Observable implements a push-based mechanism. Observer is passive and gets notified when something changed. Properly implemented it allows much more intelligent propagation of changes.


From what I know, using Observables in angular 2.0 is optional, but advised. Moreover, angular 2.0 is going to implement one-directional data flow similar to flux. Data changes propagate only downwards in DOM -- a component can directly observe / depend on data of their ancestors but not their descendants. After a change there is a guarantee that only some subtree of DOM needs update. In most cases this subtree will be much smaller than the whole DOM.

There is a great video from 2015 ng-conf benchmarking angular 1.x, react and angular 2.0. (not sure if it uses Observables though)


One last thing about Observable: it offers way more than the above description and it is a great way of dealing with asynchronous events.