I use both, because honestly, I view them as different tools for different problems.
I'll give an example from an application that I built. I had a complex WebSocket Service that received dynamic data models from a web-socket server. The service itself doesn't care what the model looks like, but, of course, the controller sure does.
When the controller is initiated, it set up a $watch
on the service data object so that it knew when it's particular data object had arrived (like waiting for Service.data.foo
to exist. As soon as that model came into existence, it was able to bind to it and crate a two-way data-bind to it, the watch became obsolete, and it was destroyed.
On the other side, the service was responsible for broadcasting certain events as well, because sometimes the client would receive literal commands from the server. For instance, the Server might request that the client send some metadata that was stored in the '$rootScope' throughout the application. an .on()
was set up in the $rootScope
during module.run()
step to listen for those commands from the server, gather needed information from other services, and call the WebSocket service back to send the data as requested. Alternatively, if I had done this using a $watch()
, I would have needed to set up some sort of arbitrary variable for it to watch, like metadataRequests
which I would need to increment every time I receive a request. A broadcast
achieves the same thing without having to live in permanent memory, like our variable would.
Essentially, I use a $watch()
when there is a specific value that I want to see change (especially if I need to know the before-and-after values), and I use events if there are more high-level conditions that have been met that the controllers need to know about.
With regards to performance, I couldn't tell you which one is going to bottleneck first, but I feel like thinking of it this way will let you use the strengths of each feature where they are strongest. For instance, if you use $on()
instead of $watch()
to look for changes in data, you will not have access to the values before and after the change, which could limit what you are trying to do.