There's more...

Adding asynchronous network behaviors to our application can also create unexpected side-effects in our application's behavior. One of the most common issues is dealing with concurrency, or what happens when multiple events are happening simultaneously.

One unexpected behavior of our BlogPosts Service's getNextPage method is that it could be clicked many times by a user before the first click finally resolves its HTTP request. These duplicate requests are a waste of network resources and would actually cause a bug, whereby duplicates of blog posts could be appended to our posts list.

A simple solution to this problem is to prevent multiple calls to our service by having our loadMorePosts event manage its own asynchronous state: ...

Get MEAN Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.