8

Improving Backend Integrations: the Interceptor Pattern

In a single-page application (SPA), communication with the backend is one of the most common tasks. In Chapter 5, Angular Services and the Singleton Pattern, we learned that the Angular component that makes this communication is called Service. However, many side tasks are common to all communications with the backend, such as header processing, authentication, and loading.

We could do this sides task on a service-by-service basis, but in addition to being an unproductive activity, the team might not be able to implement some control on the request due to the carelessness or ignorance of a new member of the team.

In order to simplify the development of side tasks for communicating with ...

Get Angular Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.