Book Image

AngularJS Web application development Cookbook

By : Matthew Frisbie
Book Image

AngularJS Web application development Cookbook

By: Matthew Frisbie

Overview of this book

Packed with easy-to-follow recipes, this practical guide will show you how to unleash the full might of the AngularJS framework. Skip straight to practical solutions and quick, functional answers to your problems without hand-holding or slogging through the basics. Avoid antipatterns and pitfalls, and squeeze the maximum amount out of the most powerful parts of the framework, from creating promise-driven applications to building an extensible event bus. Throughout, take advantage of a clear problem-solving approach that offers code samples and explanations of components you should be using in your production applications.
Table of Contents (17 chapters)
AngularJS Web Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building an event bus


Depending on the purpose of your application, you might find yourself with the need to utilize a publish-subscribe (pub-sub) architecture to accomplish certain features. AngularJS provides the proper toolkit to accomplish this, but there are considerations that need to be made to prevent performance degradation and keep the application organized.

Formerly, using the $broadcast service from a scope with a large number of descendant scopes incurred a significant performance hit due to the large number of potential listeners that needed to be handled. In the AngularJS 1.2.7 release, an optimization was introduced to $broadcast that limits the reach of the event to only the scopes that are listening for it. With this, $broadcast can be used more freely throughout your application, but there is still a void to be filled to service applications that demand a pub-sub architecture. Simply put, your application should be able to broadcast an event to subscribers throughout the...