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: ...
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