Broadcasting state changes
Another solution that was popular a few years ago was to use a broadcasting mechanism, through which application code would simply emit custom global events, along with arbitrary data. The rest of the application was then able to retrieve the data and react to the changes by listening to those global events.
The advantage of broadcasting is that different and unconnected application components can easily communicate without us having to introduce strong coupling and without us needing many unrelated components to participate in the data exchange.
Broadcasting was actually supported in Vue.js 1.x through $broadcast, as well as in older AngularJS versions through $rootScope.$broadcast. These were never heavily recommended ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access